|
| 1 | +# Changelog |
| 2 | + |
| 3 | +## v0.2.0 |
| 4 | + |
| 5 | +This release simplifies font handling, adds named colors and adds support for efficiently changing text dynamically. |
| 6 | + |
| 7 | +### Simplified Font Handling |
| 8 | + |
| 9 | +In the past, you needed to pass around multiple `Handle<Font>`s for each variant of a font (e.g. bold, italic, bold and italic, etc.). |
| 10 | + |
| 11 | +Instead, we now use a `FontRegistry` which automatically tracks which `Font`s are loaded and allows to query them by font weight, style and other factors. |
| 12 | +You can now simply specify an asset path where your fonts are stored and they will all be loaded and used inside of BBCode! |
| 13 | + |
| 14 | +```rs |
| 15 | +// Load the fonts inside of assets/fonts |
| 16 | +BbcodePlugin::new().with_fonts("fonts") |
| 17 | +``` |
| 18 | + |
| 19 | +Then inside of `BbcodeSettings`, you just specify the font family, size and color of the text to use by default: |
| 20 | + |
| 21 | +```rs |
| 22 | +BbcodeSettings::new("Fira Sans", 40., Color::WHITE) |
| 23 | +``` |
| 24 | + |
| 25 | +Additionally, the new `font` tag allows you to change the font family for parts of the text: |
| 26 | + |
| 27 | +```txt |
| 28 | +[font="JetBrains Mono"]new font family[/font] |
| 29 | +``` |
| 30 | + |
| 31 | +### Named Colors |
| 32 | + |
| 33 | +The `color`/`c` tag now also supports named colors, e.g. `[c=primary]text[/c]`. |
| 34 | +The color values are specified in the new `ColorMap` resource. |
| 35 | + |
| 36 | +Changing a value in the color map resource will dynamically update all occurrences of this color in your app! |
| 37 | + |
| 38 | +### Dynamic Text Editing |
| 39 | + |
| 40 | +Until this point, you could dynamically change the text in your app by changing `Bbcode.content`. |
| 41 | +However, this adds a performance overhead as the entire markup needs to be parsed again and the UI hierarchy reconstructed. |
| 42 | + |
| 43 | +Instead, you can now register marker components: |
| 44 | + |
| 45 | +```rs |
| 46 | +#[derive(Component, Clone)] |
| 47 | +struct TimeMarker; |
| 48 | + |
| 49 | +BbcodeSettings::new("Fira Sans", 40., Color::WHITE) |
| 50 | + // Register the marker component |
| 51 | + .with_marker("time", TimeMarker) |
| 52 | +``` |
| 53 | + |
| 54 | +And then use it with the new `m` tag: |
| 55 | + |
| 56 | +```txt |
| 57 | +Time passed: [m=time]0.0[/m] |
| 58 | +``` |
| 59 | + |
| 60 | +Finally, you can use queries to efficiently update the text: |
| 61 | + |
| 62 | +```rs |
| 63 | +fn update_text(time: Res<Time>, mut query: Query<&mut Text, With<TimeMarker>>) { |
| 64 | + for mut text in query.iter_mut() { |
| 65 | + text.sections[0].value = format!("{:.0}", time.elapsed_seconds()); |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +## Migration Guide |
| 70 | + |
| 71 | +The `BbcodePlugin` now has a constructor and allows you to load an entire folder of fonts: |
| 72 | + |
| 73 | +```rs |
| 74 | +// Load the fonts inside of assets/fonts |
| 75 | +BbcodePlugin::new().with_fonts("fonts") |
| 76 | +``` |
| 77 | + |
| 78 | +In the `BbcodeSettings` you now specify the font family, size and color of the default text: |
| 79 | + |
| 80 | +```rs |
| 81 | +BbcodeSettings::new("Fira Sans", 40., Color::WHITE) |
| 82 | +``` |
| 83 | + |
| 84 | +## v0.1.0 |
| 85 | + |
| 86 | +The initial release! |
| 87 | + |
| 88 | +Supports basic BBCode formatting with bold, italic and colored text. |
0 commit comments