Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Text2d
ignoresTextBounds
when calculating the offset for text aligment.On main a text entity positioned in the center of the window with center justification and 600px horizontal text bounds isn't centered like it should be but shifted off to the right:
(second example in the testing section below)
Fixes #14266
I already had a PR in review for this (#14270) but it used post layout adjustment (which we want to avoid) and ignored
TextBounds
.Solution
TextBounds
are present for an axis, use them instead of the size of the computed text layout size to calculate the offset.Testing
This probably looks really confusing but it should make sense if you imagine each block of text surrounded by a 300x75 rectangle that is anchored to the center of the yellow square.
The text being above the center is intended. When
TextBounds
are present, the text block's offset is calculated using itsTextBounds
not the layout size returned by cosmic-text.Probably we should add a vertical alignment setting for Text2d. Didn't do it here as this is intended for a 0.15.2 release.