bevy_vello icon indicating copy to clipboard operation
bevy_vello copied to clipboard

enhancement: Text `LineBreakBehavior`

Open simbleau opened this issue 1 year ago • 3 comments

Implement line break behavior for the Vello Text API.

simbleau avatar May 16 '24 03:05 simbleau

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.

RobertBrewitz avatar Mar 31 '25 05:03 RobertBrewitz

~~Implemented a quick version here: https://github.com/RobertBrewitz/bevy_vello/pull/1~~

RobertBrewitz avatar Mar 31 '25 06:03 RobertBrewitz

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/)

simbleau avatar Apr 03 '25 19:04 simbleau