bevy_vello
bevy_vello copied to clipboard
enhancement: Text `LineBreakBehavior`
Implement line break behavior for the Vello Text API.
When parley is in place it's possible to implement easily in the font render function.
let max_advance = Some(200.); // pixels I think
layout.break_all_lines(max_advance);
if max_advance.is_some() {
layout.align(
max_advance,
parley::Alignment::Justified,
parley::AlignmentOptions::default(),
);
}
The tricky part is how to expose the functionality API wise.
~~Implemented a quick version here: https://github.com/RobertBrewitz/bevy_vello/pull/1~~
I think there's still work here to consider @RobertBrewitz
Bevy has many line break behaviors,
pub enum LineBreak {
WordBoundary,
AnyCharacter,
WordOrCharacter,
NoWrap,
}
See https://docs.rs/bevy/latest/bevy/text/enum.LineBreak.html
In use, as a component:
TextLayout::new(JustifyText::Left, LineBreak::WordBoundary)
(example: https://bevyengine.org/examples/ui-user-interface/text-wrap-debug/)