Skip to content

Commit

Permalink
Update documentation with m tag and new font loading (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimJentzsch authored Jul 26, 2024
1 parent 9fb125e commit 994518c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# bevy_mod_bbcode

Use BBCode-formatted text in Bevy.
Rich text support in Bevy using a custom [BBCode](https://en.wikipedia.org/wiki/BBCode) markup flavor.

## Bevy Compatibility

Expand All @@ -24,7 +24,8 @@ use bevy_mod_bbcode::{BbcodeBundle, BbcodePlugin, BbcodeSettings};

fn main() {
App::new()
.add_plugins((DefaultPlugins, BbcodePlugin))
// Register the font files stored in `assets/fonts`
.add_plugins((DefaultPlugins, BbcodePlugin::new().with_fonts("fonts")))
.add_systems(Startup, setup)
.run();
}
Expand All @@ -34,14 +35,8 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {

commands.spawn(BbcodeBundle::from_content(
"test [b]bold[/b] with [i]italic[/i] and [c=#ff00ff]color[/c]",
BbcodeSettings {
regular_font: asset_server.load("fonts/FiraSans-Regular.ttf"),
bold_font: asset_server.load("fonts/FiraSans-Bold.ttf"),
italic_font: asset_server.load("fonts/FiraSans-Italic.ttf"),

font_size: 40.,
color: Color::WHITE,
},
// Use the "Fira Sans" font family with a default font size of 40
BbcodeSettings::new("Fira Sans", 40., Color::WHITE),
));
}
```
Expand All @@ -50,14 +45,17 @@ See `examples` for more usage patterns!

### Supported Tags

| Tag | Usage |
| ------------------------ | ------------ |
| `[b]bold[/b]` | Bold text |
| `[i]italic[/i]` | Italic text |
| `[c=#ff00ff]colored[/c]` | Colored text |
| Tag | Usage |
| ------------------------ | ----------------------------------------------------------------------------------------- |
| `[b]bold[/b]` | Bold text |
| `[i]italic[/i]` | Italic text |
| `[c=#ff00ff]colored[/c]` | Colored text |
| `[m=foo]test[/m]` | Add a marker component to the `Text` "test", registered via `BbcodeSettings::with_marker` |

## License

This project is licensed under the terms of the [MIT](LICENSE-MIT) or [Apache 2.0](LICENSE-APACHE) 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`](assets/CREDITS.md).
2 changes: 2 additions & 0 deletions examples/static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use bevy_mod_bbcode::{BbcodeBundle, 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();
Expand All @@ -13,6 +14,7 @@ fn setup(mut commands: Commands) {

commands.spawn(BbcodeBundle::from_content(
"test [b]bold with [i]italic[/i][/b] 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),
));
}

0 comments on commit 994518c

Please sign in to comment.