@@ -15,15 +15,15 @@ pub struct Text {
1515 /// Should not affect its position within a container.
1616 pub alignment : TextAlignment ,
1717 /// How the text should linebreak when running out of the bounds determined by max_size
18- pub linebreak_behaviour : TextLineBreakBehaviour ,
18+ pub linebreak_behaviour : BreakLineOn ,
1919}
2020
2121impl Default for Text {
2222 fn default ( ) -> Self {
2323 Self {
2424 sections : Default :: default ( ) ,
2525 alignment : TextAlignment :: Left ,
26- linebreak_behaviour : TextLineBreakBehaviour :: Unicode ,
26+ linebreak_behaviour : BreakLineOn :: WordBoundary ,
2727 }
2828 }
2929}
@@ -177,24 +177,22 @@ impl Default for TextStyle {
177177/// Determines how lines will be broken when preventing text from running out of bounds.
178178#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , Reflect , Serialize , Deserialize ) ]
179179#[ reflect( Serialize , Deserialize ) ]
180- pub enum TextLineBreakBehaviour {
181- /// Lines will be broken up at the nearest word boundary, usually at a space.<br/>
182- /// This behaviour suits most cases, as it keeps words intact. Aims to implement the Unicode line breaking algorithm.
183- Unicode ,
184- /// Lines will be broken without discrimination at the first character that runs out of bounds.<br/>
185- /// This is closer to the behaviour one might expect from a terminal.
180+ pub enum BreakLineOn {
181+ /// Uses the [Unicode Line Breaking Algorithm](https://www.unicode.org/reports/tr14/).<br/>
182+ /// Lines will be broken up at the nearest suitable word boundary, usually a space.<br/>
183+ /// This behaviour suits most cases, as it keeps words intact across linebreaks.<br/>
184+ WordBoundary ,
185+ /// Lines will be broken without discrimination on any character that would leave bounds.<br/>
186+ /// This is closer to the behaviour one might expect from text in a terminal. <br/>
187+ /// However it may lead to words being broken up across linebreaks<br />
186188 AnyCharacter ,
187189}
188190
189- impl From < TextLineBreakBehaviour > for glyph_brush_layout:: BuiltInLineBreaker {
190- fn from ( val : TextLineBreakBehaviour ) -> Self {
191+ impl From < BreakLineOn > for glyph_brush_layout:: BuiltInLineBreaker {
192+ fn from ( val : BreakLineOn ) -> Self {
191193 match val {
192- TextLineBreakBehaviour :: Unicode => {
193- glyph_brush_layout:: BuiltInLineBreaker :: UnicodeLineBreaker
194- }
195- TextLineBreakBehaviour :: AnyCharacter => {
196- glyph_brush_layout:: BuiltInLineBreaker :: AnyCharLineBreaker
197- }
194+ BreakLineOn :: WordBoundary => glyph_brush_layout:: BuiltInLineBreaker :: UnicodeLineBreaker ,
195+ BreakLineOn :: AnyCharacter => glyph_brush_layout:: BuiltInLineBreaker :: AnyCharLineBreaker ,
198196 }
199197 }
200198}
0 commit comments