bevy/examples/2d
Molot2032 cef56a0d47 Allow users of Text/TextBundle to choose from glyph_brush_layout's BuiltInLineBreaker options. (#7283)
# Objective
Currently, Text always uses the default linebreaking behaviour in glyph_brush_layout `BuiltInLineBreaker::Unicode` which breaks lines at word boundaries. However, glyph_brush_layout also supports breaking lines at any character by setting the linebreaker to `BuiltInLineBreaker::AnyChar`. Having text wrap character-by-character instead of at word boundaries is desirable in some cases - consider that consoles/terminals usually wrap this way.

As a side note, the default Unicode linebreaker does not seem to handle emergency cases, where there is no word boundary on a line to break at. In that case, the text runs out of bounds. Issue #1867 shows an example of this.

## Solution
Basically just copies how TextAlignment is exposed, but for a new enum TextLineBreakBehaviour.
This PR exposes glyph_brush_layout's two simple linebreaking options (Unicode, AnyChar) to users of Text via the enum TextLineBreakBehaviour (which just translates those 2 aforementioned options), plus a method 'with_linebreak_behaviour' on Text and TextBundle. 

## Changelog

Added `Text::with_linebreak_behaviour`
Added `TextBundle::with_linebreak_behaviour` 
`TextPipeline::queue_text` and `GlyphBrush::compute_glyphs` now need a TextLineBreakBehaviour argument, in order to pass through the new field.
Modified the `text2d` example to show both linebreaking behaviours. 


## Example
Here's what the modified example looks like
![image](https://user-images.githubusercontent.com/117271367/213589184-b1a54bf3-116c-4721-8cb6-1cb69edb3070.png)
2023-01-21 00:17:11 +00:00
..
2d_shapes.rs Rename shapes examples for consistency (#6082) 2022-09-25 00:57:07 +00:00
mesh2d.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
mesh2d_manual.rs Changed Msaa to Enum (#7292) 2023-01-20 14:25:21 +00:00
mesh2d_vertex_color_texture.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
move_sprite.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
pixel_perfect.rs Add pixelated Bevy to assets and an example (#6408) 2022-11-14 22:15:46 +00:00
rotation.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
sprite.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
sprite_flipping.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
sprite_sheet.rs Sprite sheet example: specify animation indices (#6861) 2022-12-11 18:22:10 +00:00
text2d.rs Allow users of Text/TextBundle to choose from glyph_brush_layout's BuiltInLineBreaker options. (#7283) 2023-01-21 00:17:11 +00:00
texture_atlas.rs asset: make HandleUntyped::id private (#7076) 2023-01-04 23:40:43 +00:00
transparency_2d.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00