Enhancement: FontVariant and FontStyle applied to ranges
Parley has support for applying font styles and variants to sub-sections of text, e.g: "The quick brown fox jumps over the lazy dog"
How this would be exposed I am not sure, maybe something like "BB Code".
Depends on #130
In Bevy I believe they model this with TextSpans, where each span can have a different style and they get computed together with other spans.
We may need a higher-order container to do something like this. Thoughts @RobertBrewitz ?
Could be related to #51 and #50
struct VelloText {
sections: Vec<VelloTextSection>
layout: VelloTextLayout,
}
struct VelloTextLayout {
line_break_behavior: LineBreakBehavior,
text_justify: TextJustify,
max_width: f32,
...
}
I'll dig a little what the plan is for bevy_ui to get a little better informed myself.
We may need a higher-order container to do something like this. Thoughts @RobertBrewitz ?
Could be related to #51 and #50
struct VelloText { sections: Vec<VelloTextSection> layout: VelloTextLayout, }
struct VelloTextLayout { line_break_behavior: LineBreakBehavior, text_justify: TextJustify, max_width: f32, ... }
I have been think about this on and off; Might it be better to just leverage the component relation/hierarchy API in Bevy, and not use our own Vec of text sections? My gut feeling is that it might be a bit unnecessary complexity to start managing our own Vec.
Rust/pseudo code:
fn bold_text(value: &str) -> Bundle {
VelloTextSection {
value,
style: VelloFontStyle {
weight: 900.,
..default()
},
..default()
}
}
fn text(value: &str) -> Bundle {
VelloTextSection {
value,
..default()
}
}
fn spawn_text(mut cmd: Commands) {
cmd.spawn(Transform::from_xyz(1.,1.,1.))
.with_children(|parent| {
parent.spawn(text("I have some normal text,"));
parent.spawn(bold_text("and some bold text,"));
parent.spawn(text("that I want to render"));
});
}
On second thought, I recall entity relationships not having deterministic ordering, in that case your suggestion is more sound.
Yeah, furthermore I think a text_spans example could be added, since the current text example is good as is. Very happy with it!