bevyengine / bevyengine/bevy

Squeezed text nodes early text wrap

Open
#8,518 4 comments 0 reactions 0 assignees View on GitHub
A-Text A-UI C-Bug
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version

Main [ee697f8](https://github.com/bevyengine/bevy/commit/ee697f820c0b164cf2825b9c8e932fc8cee24a2c)

## What you did

```rust
use bevy::prelude::*;

fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
}

fn setup(mut commands: Commands, asset_server: Res) {
let font = asset_server.load("FiraMono-Medium.ttf");
let text_style = TextStyle {
font,
font_size: 20.,
color: Color::WHITE,
};
let message = "one two three four";
commands.spawn(Camera2dBundle::default());

commands
.spawn(NodeBundle {
style: Style {
flex_direction: FlexDirection::Column,
size: Size::width(Val::Percent(100.)),
..Default::default()
},
..Default::default()
})
.with_children(|commands| {
let test_cases = [
(Val::Percent(100.), Color::RED),
(Val::Px(10000.), Color::YELLOW),
(Val::Percent(50.), Color::GREEN),
];

for (width, bg_color) in test_cases {
commands
.spawn(NodeBundle::default())
.with_children(|commands| {
commands.spawn(
TextBundle::from_section(
message,
text_style.clone(),
)
.with_background_color(Color::BLACK),
);

commands.spawn(NodeBundle {
style: Style {
size: Size::width(width),
..Default::default()
},
background_color: bg_color.into(),
..Default::default()
});
});
}
});
}
```

## What went wrong

text_wrap_bug

## Additional Information

Doesn't seem to be directly related to #8516, but it'll be much easier to isolate the cause with #8516 fixed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.