-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Size in TextLayoutInfo does not correspond to actual Text2d dimensions with non-one scale factor #7787
Comments
rparrett
added
C-Bug
An unexpected or incorrect behavior
S-Needs-Triage
This issue needs to be labelled
labels
Feb 22, 2023
This is my fault, I should have considered this when I made this change. I think this points to a place the code can be simplified and there isn't any need for TextInfo to be a scaled value. It's just inverted again in the extraction function anyway. I'll make a short PR that should fix it now. |
rparrett
added
A-UI
Graphical user interfaces, styles, layouts, and widgets
and removed
S-Needs-Triage
This issue needs to be labelled
labels
Feb 23, 2023
github-merge-queue bot
pushed a commit
that referenced
this issue
Sep 11, 2023
…t a scaled value. (#7794) # Objective `TextLayoutInfo::size` isn't the drawn size of the text, but a scaled value. This is fragile, counter-intuitive and makes it awkward to retrieve the correct value. ## Solution Multiply `TextLayoutInfo::size` by the reciprocal of the window's scale factor after generating the text layout in `update_text2d_layout` and `bevy_ui::widget::text_system`. --- fixes: #7787 ## Changelog * Multiply `TextLayoutInfo::size` by the reciprocal of the scale factor after text computation to reflect the actual size of the text as drawn. * Reorder the operations in `extract_text2d_sprite` to apply the alignment offset before the scale factor scaling. ## Migration Guide The `size` value of `TextLayoutInfo` is stored in logical pixels and has been renamed to `logical_size`. There is no longer any need to divide by the window's scale factor to get the logical size.
rdrpenguin04
pushed a commit
to rdrpenguin04/bevy
that referenced
this issue
Jan 9, 2024
…t a scaled value. (bevyengine#7794) # Objective `TextLayoutInfo::size` isn't the drawn size of the text, but a scaled value. This is fragile, counter-intuitive and makes it awkward to retrieve the correct value. ## Solution Multiply `TextLayoutInfo::size` by the reciprocal of the window's scale factor after generating the text layout in `update_text2d_layout` and `bevy_ui::widget::text_system`. --- fixes: bevyengine#7787 ## Changelog * Multiply `TextLayoutInfo::size` by the reciprocal of the scale factor after text computation to reflect the actual size of the text as drawn. * Reorder the operations in `extract_text2d_sprite` to apply the alignment offset before the scale factor scaling. ## Migration Guide The `size` value of `TextLayoutInfo` is stored in logical pixels and has been renamed to `logical_size`. There is no longer any need to divide by the window's scale factor to get the logical size.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bevy version
main
Relevant system information
(Scale factor 2.0)
What you did
Spawn a
Text2dBundle
with aSpriteBundle
in the background, sized according toTextLayoutInfo.size
.What went wrong
I expected a black box underneath my text, with 4px of padding.
Instead, the black box is 2x the size of the text with an additional 4px of padding.
Additional information
I had previously used
Text2dSize
for this purpose which worked fine, but it was removed in #6807.I can/will work around this by querying for the scale factor and dividing, but it seems like a hack.
The text was updated successfully, but these errors were encountered: