Skip to content

Commit 8b75a65

Browse files
committed
Fix formatting for TextLineBreakBehaviour changes
Ran cargo fmt
1 parent 7004552 commit 8b75a65

File tree

5 files changed

+43
-23
lines changed

5 files changed

+43
-23
lines changed

crates/bevy_text/src/glyph_brush.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ use bevy_render::texture::Image;
55
use bevy_sprite::TextureAtlas;
66
use bevy_utils::tracing::warn;
77
use glyph_brush_layout::{
8-
FontId, GlyphPositioner, Layout, SectionGeometry, SectionGlyph, SectionText, ToSectionText, BuiltInLineBreaker,
8+
BuiltInLineBreaker, FontId, GlyphPositioner, Layout, SectionGeometry, SectionGlyph,
9+
SectionText, ToSectionText,
910
};
1011

1112
use crate::{
1213
error::TextError, Font, FontAtlasSet, FontAtlasWarning, GlyphAtlasInfo, TextAlignment,
13-
TextSettings, YAxisOrientation, TextLineBreakBehaviour,
14+
TextLineBreakBehaviour, TextSettings, YAxisOrientation,
1415
};
1516

1617
pub struct GlyphBrush {

crates/bevy_text/src/pipeline.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ use glyph_brush_layout::{FontId, SectionText};
1111

1212
use crate::{
1313
error::TextError, glyph_brush::GlyphBrush, scale_value, Font, FontAtlasSet, FontAtlasWarning,
14-
PositionedGlyph, TextAlignment, TextSection, TextSettings, YAxisOrientation, TextLineBreakBehaviour,
14+
PositionedGlyph, TextAlignment, TextLineBreakBehaviour, TextSection, TextSettings,
15+
YAxisOrientation,
1516
};
1617

1718
#[derive(Default, Resource)]
@@ -76,9 +77,9 @@ impl TextPipeline {
7677
})
7778
.collect::<Result<Vec<_>, _>>()?;
7879

79-
let section_glyphs = self
80-
.brush
81-
.compute_glyphs(&sections, bounds, text_alignment, linebreak_behaviour)?;
80+
let section_glyphs =
81+
self.brush
82+
.compute_glyphs(&sections, bounds, text_alignment, linebreak_behaviour)?;
8283

8384
if section_glyphs.is_empty() {
8485
return Ok(TextLayoutInfo::default());

crates/bevy_text/src/text.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ impl Text {
107107
self
108108
}
109109

110-
pub const fn with_linebreak_behaviour(mut self, linebreak_behaviour: TextLineBreakBehaviour) -> Self {
110+
pub const fn with_linebreak_behaviour(
111+
mut self,
112+
linebreak_behaviour: TextLineBreakBehaviour,
113+
) -> Self {
111114
self.linebreak_behaviour = linebreak_behaviour;
112115
self
113116
}
@@ -194,8 +197,12 @@ pub enum TextLineBreakBehaviour {
194197
impl From<TextLineBreakBehaviour> for glyph_brush_layout::BuiltInLineBreaker {
195198
fn from(val: TextLineBreakBehaviour) -> Self {
196199
match val {
197-
TextLineBreakBehaviour::Unicode => glyph_brush_layout::BuiltInLineBreaker::UnicodeLineBreaker,
198-
TextLineBreakBehaviour::AnyCharacter => glyph_brush_layout::BuiltInLineBreaker::AnyCharLineBreaker,
200+
TextLineBreakBehaviour::Unicode => {
201+
glyph_brush_layout::BuiltInLineBreaker::UnicodeLineBreaker
202+
}
203+
TextLineBreakBehaviour::AnyCharacter => {
204+
glyph_brush_layout::BuiltInLineBreaker::AnyCharLineBreaker
205+
}
199206
}
200207
}
201208
}

crates/bevy_ui/src/node_bundles.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use bevy_render::{
99
prelude::{Color, ComputedVisibility},
1010
view::Visibility,
1111
};
12-
use bevy_text::{Text, TextAlignment, TextSection, TextStyle, TextLineBreakBehaviour};
12+
use bevy_text::{Text, TextAlignment, TextLineBreakBehaviour, TextSection, TextStyle};
1313
use bevy_transform::prelude::{GlobalTransform, Transform};
1414

1515
/// The basic UI node
@@ -154,7 +154,10 @@ impl TextBundle {
154154
}
155155

156156
/// Returns this [`TextBundle`] with a new [`TextLineBreakBehaviour`] on [`Text`].
157-
pub const fn with_linebreak_behaviour(mut self, linebreak_behaviour: TextLineBreakBehaviour) -> Self {
157+
pub const fn with_linebreak_behaviour(
158+
mut self,
159+
linebreak_behaviour: TextLineBreakBehaviour,
160+
) -> Self {
158161
self.text.linebreak_behaviour = linebreak_behaviour;
159162
self
160163
}

examples/2d/text2d.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
//! For an example on how to render text as part of a user interface, independent from the world
66
//! viewport, you may want to look at `2d/contributors.rs` or `ui/text.rs`.
77
8-
use bevy::{prelude::*, text::{Text2dBounds, TextLineBreakBehaviour}};
8+
use bevy::{
9+
prelude::*,
10+
text::{Text2dBounds, TextLineBreakBehaviour},
11+
};
912

1013
fn main() {
1114
App::new()
@@ -63,7 +66,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
6366
));
6467
// Demonstrate text wrapping
6568
let slightly_smaller_text_style = TextStyle {
66-
font: font,
69+
font,
6770
font_size: 42.0,
6871
color: Color::WHITE,
6972
};
@@ -81,9 +84,12 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
8184
})
8285
.with_children(|builder| {
8386
builder.spawn(Text2dBundle {
84-
text: Text::from_section("this text wraps in the box\n(Unicode linebreaks)", slightly_smaller_text_style.clone())
85-
.with_alignment(TextAlignment::Left)
86-
.with_linebreak_behaviour(TextLineBreakBehaviour::Unicode),
87+
text: Text::from_section(
88+
"this text wraps in the box\n(Unicode linebreaks)",
89+
slightly_smaller_text_style.clone(),
90+
)
91+
.with_alignment(TextAlignment::Left)
92+
.with_linebreak_behaviour(TextLineBreakBehaviour::Unicode),
8793
text_2d_bounds: Text2dBounds {
8894
// Wrap text in the rectangle
8995
size: box_size,
@@ -94,10 +100,9 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
94100
});
95101
});
96102

97-
98-
let other_box_size = Vec2::new(300.0, 200.0);
99-
let other_box_position = Vec2::new(320.0, -250.0);
100-
commands
103+
let other_box_size = Vec2::new(300.0, 200.0);
104+
let other_box_position = Vec2::new(320.0, -250.0);
105+
commands
101106
.spawn(SpriteBundle {
102107
sprite: Sprite {
103108
color: Color::rgb(0.20, 0.3, 0.70),
@@ -109,9 +114,12 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
109114
})
110115
.with_children(|builder| {
111116
builder.spawn(Text2dBundle {
112-
text: Text::from_section("this text wraps in the box\n(AnyCharacter linebreaks)", slightly_smaller_text_style)
113-
.with_alignment(TextAlignment::Left)
114-
.with_linebreak_behaviour(TextLineBreakBehaviour::AnyCharacter),
117+
text: Text::from_section(
118+
"this text wraps in the box\n(AnyCharacter linebreaks)",
119+
slightly_smaller_text_style,
120+
)
121+
.with_alignment(TextAlignment::Left)
122+
.with_linebreak_behaviour(TextLineBreakBehaviour::AnyCharacter),
115123
text_2d_bounds: Text2dBounds {
116124
// Wrap text in the rectangle
117125
size: other_box_size,

0 commit comments

Comments
 (0)