-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JustifyText::Center
doesn't place a text in the center of Text2dBounds
#14266
Comments
@m2ym out of interest does the response #14251 (comment) help in your case? |
This is a bug. The
|
As a temporary fix you can add this system to fn fix_text2d_layout(
mut query: Query<&mut TextLayoutInfo, (Changed<TextLayoutInfo>, With<Anchor>)>,
) {
for mut layout_info in query.iter_mut() {
let mut min_x = f32::MAX;
for glyph in layout_info.glyphs.iter() {
min_x = (glyph.position.x - 0.5 * glyph.size.x).min(min_x);
}
for glyph in layout_info.glyphs.iter_mut() {
glyph.position.x -= min_x;
}
}
} Should work with both bevy 0.14 and main. |
@ickshonpe The temporary fix works. Thanks for your work and a very quick response! |
Bevy version
v0.14.0
What you did
Text2dBounds
)What went wrong
The text (
"hello"
in the code above) is not placed at the center, but at the right.In v0.13.2, the text is rendered as expected.
The text was updated successfully, but these errors were encountered: