Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation with m tag and new font loading #7

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
));
}