Support for line breaking on very long words in UI
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## What problem does this solve or what need does it fill?
Currently, the line break options available for UI text support breaking on `WordBoundary` and breaking on `AnyCharacter`. However, when selecting break on `WordBoundary`, very long words are not broken up when the maximum space is smaller than the width of a very long word. This has a tendency to break UI layouts, as the text clips over the edge.
In most cases, this has no effect on the user interface, as situations where a single word is longer than the available space are generally rare, but in cases where user input is available, this limitation becomes extremely obvious. Typing out a very long word for a character name or something will easily break most user interface layouts in some way by clipping over the edge.
## What solution would you like?
I would propose adding a third line break option that acts like a standard `WordBoundary` line break option, but will also soft break on very long words.
## What alternative(s) have you considered?
I have considered writing my own line breaking implementation, however due to the way this is implemented, this is quite difficult. The original `graph_brush_layout` library has support for writing custom line break implementations, as shown [here](https://docs.rs/glyph_brush_layout/latest/glyph_brush_layout/trait.LineBreaker.html), but this code is hidden within Bevy's implementation and not readily available to users.
## Additional context
None.
Contributor guide
Research direction
Locate Bevy's UI text line-breaking implementation and trace how the existing WordBoundary option is wired. Compare that behavior with the graph_brush_layout LineBreaker documentation mentioned in the issue. Done means a third option soft-breaks words longer than the available width while preserving the current WordBoundary and AnyCharacter behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100