On macOS, just altering this string slice causes the vertical position of the text to change!

The first shot is the normal "Text Example". The second alters it to be "Text Example -- notice anything?". The third is "Text Example -- notice anything? Even more text 1234567890"
Suggested labels: bug | ui
I agree with you this is definitely a bug thanks for letting us know :) If anyone is reading this can you confirm the bug repros on other platforms too 馃槉
I'm on Archlinux , here's the same texts:
"Text Example"

"Text Example -- notice anything?"

"Text Example -- notice anything? Even more text 1234567890"

Same issue here
This happens due to how the flexbox engine interacts with fixed size elements:
20 * 80/100 = 16. So, our Node now has a size of (w: 80, h: 20px). __This is different to the calculated size!__node.size by 2 to get the center and offset that with is transform. But then go on to draw with the original size: https://github.com/bevyengine/bevy/blob/8106f770de2ae3c841651499e0637123d7ae6688/crates/bevy_ui/src/widget/text.rs#L64-L81This then results in the behavior we see now: A smaller height divided by two makes for an 'upwards' growing text, when in actuality it should be shrinking to fit the available width.
I am not sure what the ideal solution is here. Either the text overflows, or it gets smaller and smaller. Another option is to have it break into a new line (if there is space?)
In my use-case I would like to wrap. From my naive standpoint of never having had to implement a text layout system, it seems like wrap vs. shrink vs. overflow should all be supported via some configurable option. I don't know how hard that is to do.
I have this issue, my "fix" to have the expected placement is to set the Style component of the TextComponents, with the height equal to the font size:
TextComponents {
style: Style {
size: Size {
height: Val::Px(40.),
..Default::default()
},
..Default::default()
},
text: Text {
value: "Text example",
font,
style: TextStyle {
color: Color::WHITE,
font_size: 40.,
},
},
..Default::default()
}
Most helpful comment
This happens due to how the flexbox engine interacts with fixed size elements:
20 * 80/100 = 16. So, ourNodenow has a size of(w: 80, h: 20px). __This is different to the calculated size!__node.sizeby 2 to get the center and offset that with is transform. But then go on to draw with the original size: https://github.com/bevyengine/bevy/blob/8106f770de2ae3c841651499e0637123d7ae6688/crates/bevy_ui/src/widget/text.rs#L64-L81This then results in the behavior we see now: A smaller height divided by two makes for an 'upwards' growing text, when in actuality it should be shrinking to fit the available width.
I am not sure what the ideal solution is here. Either the text overflows, or it gets smaller and smaller. Another option is to have it break into a new line (if there is space?)