From a39e4aa54804d3f4be6cc9cb23795371710c7d19 Mon Sep 17 00:00:00 2001 From: Tim Jentzsch Date: Fri, 26 Jul 2024 14:54:26 +0200 Subject: [PATCH] Update documentation with m tag and new font loading --- README.md | 28 +++++++++++++--------------- examples/static.rs | 2 ++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index a767585..a4429b7 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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(); } @@ -34,14 +35,8 @@ fn setup(mut commands: Commands, asset_server: Res) { 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), )); } ``` @@ -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). diff --git a/examples/static.rs b/examples/static.rs index 213cb23..8e3b7f8 100644 --- a/examples/static.rs +++ b/examples/static.rs @@ -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(); @@ -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), )); }