Description
Bevy version
0.8
Relevant system information
Win10 / Vulkan
AdapterInfo { name: "NVIDIA GeForce RTX 2070", vendor: 4318, device: 7938, device_type: DiscreteGpu, backend: Vulkan }
What you did
To work around #1490, constrain the size of a text in an attempt to wrap it:
.spawn_bundle(NodeBundle {
style: Style {
flex_direction: FlexDirection::ColumnReverse, // top to bottom
align_items: AlignItems::FlexStart, // align content top
..default()
},
color: UiColor(Color::rgba_u8(122, 47, 125, 214)),
..default()
})
.with_children(|parent| {
parent
.spawn_bundle(TextBundle {
text: Text::from_section(
"",
TextStyle {
font: font.clone(),
font_size: 17.0,
color: Color::GRAY,
},
),
style: Style {
size: Size::new(Val::Px(490.), Val::Auto), // #1490 - Text wrapping should work with a percent width
..default()
},
..default()
});
});
What went wrong
Without the size, or with a percentage (#1490):
With the code above:
But now with a shorter text and the same size constraint, some top padding appeared:
And it's proportional to the constraint width, here's for 370.
instead of 490.
:
When the constraint reaches the actual calculated text size, the padding disappear. When going further below, the text as expected starts to wrap again.
Additional information
The text vertical alignment is ignored, so cannot even work around by vertically aligning to top. I'm not sure with the size is counted toward the text wrapping, since the size is that of the node, whereas text wrapping should work with the actual calculated size of the glyphs.