#rich-text #bevy-ui #bevy #gamedev #tiny #helper #style

bevy_simple_rich_text

A tiny rich text helper for Bevy

2 unstable releases

0.2.0 Dec 1, 2024
0.1.0 Jul 5, 2024

#1797 in Game dev

Download history 5/week @ 2024-09-23 2/week @ 2024-10-14 4/week @ 2024-11-04 36/week @ 2024-11-25 95/week @ 2024-12-02 6/week @ 2024-12-09

137 downloads per month

MIT/Apache

35KB
336 lines

bevy_simple_rich_text

crates.io docs Following released Bevy versions

A tiny, unambitious rich text helper for bevy_ui with a simple bbcode-inspired syntax.

Usage

// Register style tags by spawning `StyleTag` with `TextFont`, `TextColor`,
// and any other arbitrary Component.
commands.spawn((
    StyleTag::new("lg"),
    TextFont {
        font_size: 40.,
        ..default()
    },
));
commands.spawn((
    StyleTag::new("fancy"),
    TextColor(Color::hsl(0., 0.9, 0.7)),
    FancyText,
));

// And use them
commands.spawn(RichText::new("[lg]Hello [lg,fancy]World"));

See also examples/advanced.rs.

Performance

Modifying a RichText completely rebuilds the TextSpans, so it's probably pretty slow.

But you can attach arbitrary marker components to styles to achieve fast animations.

Compatibility

bevy_simple_rich_text bevy
0.2 0.15
0.1 0.14

Contributing

Please feel free to open a PR. The goal of this project isn't to support every feature or use-case, but to be good enough for simple projects while remaining very maintainable.

Please keep PRs small and scoped to a single feature or fix.

Dependencies

~53–85MB
~1.5M SLoC