https://github.com/rparrett/bevy_simple_rich_text
A tiny, unambitious rich text helper for bevy_ui.
https://github.com/rparrett/bevy_simple_rich_text
bevy game-development rust
Last synced: 5 months ago
JSON representation
A tiny, unambitious rich text helper for bevy_ui.
- Host: GitHub
- URL: https://github.com/rparrett/bevy_simple_rich_text
- Owner: rparrett
- License: other
- Created: 2024-07-05T00:37:00.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-01T22:06:05.000Z (7 months ago)
- Last Synced: 2025-02-07T13:47:24.958Z (5 months ago)
- Topics: bevy, game-development, rust
- Language: Rust
- Homepage:
- Size: 91.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bevy_simple_rich_text
[](https://crates.io/crates/bevy_simple_rich_text)
[](https://docs.rs/bevy_simple_rich_text)
[](https://bevyengine.org/learn/book/plugin-development/#main-branch-tracking)A tiny, unambitious rich text helper for `bevy_ui` with a simple bbcode-inspired syntax.
## Usage
```rust
// 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`](./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.