-
-
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
Line Break doesn't clear trailing whitespace #12319
Comments
I suspect the issue would be on Bevy's end rather than |
I found the areas where this calculation is performed. The top-most function is where the bounding box calculation itself it done, adding the size of the character to the bounding box. These characters are not filtered by type, so all characters are counted. bevy/crates/bevy_text/src/glyph_brush.rs Lines 207 to 234 in 4cd53cc
I imagine simply skipping invisible characters is a valid solution to this problem, right? Spaces between words would not affect the bounding box, while prefixing and trailing white space would be properly pruned. The |
I am not sure anymore. Imagine the string Either way, I think the most reliable way of determining if a glyph is visible would be "did I am starting to think that maybe the linebreaker should be removing these spaces. |
I agree. Filtering white spaces manually would also remove the leading spaces people would use for purposes such as indention. The line breaker algorithm provided by |
This seems to have been fixed by #10193. Could someone confirm? |
I won't be able to for a while because I use |
Bevy version
0.13.0
[Optional] Relevant system information
What you did
Create a
TextBundle
node within a parentNodeBundle
of a fixed size. The parent node centers the child node usingalign_items
,align_content
,justify_items
, andjustify_content
. The text should contain several words and be set to line break on word boundry. The text is set to justify center.What went wrong
When the line break occurs, the white space char is kept in the same position. This causes the renderer to include this char in the bounding box and thus shifting the center alignment of the text.
Additional information
This will cause the text to be off-center. The effect can clearly be seen with background colors enabled.
As you can see in the image above, the space between "Streamline" and "UI" is kept in place, causing the text to be shifted by half a char width to the left.
The text was updated successfully, but these errors were encountered: