4 releases (2 breaking)

new 0.3.0 Nov 30, 2024
0.3.0-rc.1 Nov 9, 2024
0.2.0 Jul 28, 2024
0.1.0 Jul 21, 2024

#450 in Game dev

Download history 2/week @ 2024-08-05 18/week @ 2024-09-02 2/week @ 2024-09-09 7/week @ 2024-09-23 1/week @ 2024-09-30 1/week @ 2024-10-07 91/week @ 2024-11-04 22/week @ 2024-11-11 6/week @ 2024-11-18

119 downloads per month

MIT/Apache

98KB
754 lines

bevy_mod_bbcode

Rich text support in Bevy using a custom BBCode markup flavor.

Bevy Compatibility

bevy version bevy_mod_bbcode version
0.15 0.3
0.14 0.1 - 0.2

Installation

cargo add bevy_mod_bbcode

Usage

Instead of spawning Text, spawn Bbcode!

use bevy::prelude::*;
use bevy_mod_bbcode::{Bbcode, BbcodePlugin, BbcodeSettings};

fn main() {
    App::new()
        // Register the font files stored in `assets/fonts`
        .add_plugins((DefaultPlugins, BbcodePlugin::new().with_fonts("fonts")))
        .add_systems(Startup, setup)
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2d);

    commands.spawn((Bbcode::new(
        r"test [b]bold[/b] with [i]italic[/i] and [c=#ff00ff]color[/c]"),
        // Use the "Fira Sans" font family with a default font size of 40
        BbcodeSettings::new("Fira Sans", 40., Color::WHITE),
    ));
}

See examples for more usage patterns!

Supported Tags

  • b: [b]bold[/b] text
  • i: [i]italic[/i] text
  • c: [c=#ff0000]colored[/c] text
    • Register named colors via ResMut<ColorMap> and use the names instead of hex values
  • m: [m=foo]text with marker component[/m]
    • Register marker components via BbcodeSettings::with_marker and use them to update text dynamically
  • font: [font="Fira Sans"]change the font family[/font]

License

This project is licensed under the terms of the MIT or Apache 2.0 license at your choice.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Note that the assets used in the examples might use different licenses, see assets/CREDITS.md.

Dependencies

~53–86MB
~1.5M SLoC