Fix iOS text positioning for center and right alignment - #437
Open
ldalzottomp wants to merge 3 commits into
Open
ldalzottomp wants to merge 3 commits into
ldalzottomp wants to merge 3 commits into
Conversation
ldalzottomp
marked this pull request as draft
September 14, 2026 11:58
ldalzottomp
force-pushed
the
ldz/ios-wrong-alignment
branch
from
September 14, 2026 12:16
7ead513 to
c8d970c
Compare
ldalzottomp
marked this pull request as ready for review
September 14, 2026 12:17
ldalzottomp
commented
Sep 14, 2026
| ); | ||
| } | ||
|
|
||
| async function runMultilineTextAlignmentFeature() { |
Author
There was a problem hiding this comment.
Disclaimer, this function has been autogenerated. The issue is reproduced without the fix (see the images in the PR description)
ldalzottomp
marked this pull request as draft
September 14, 2026 12:19
ldalzottomp
force-pushed
the
ldz/ios-wrong-alignment
branch
from
September 14, 2026 12:21
c8d970c to
a53414d
Compare
ldalzottomp
marked this pull request as ready for review
September 14, 2026 12:22
ldalzottomp
force-pushed
the
ldz/ios-wrong-alignment
branch
from
September 14, 2026 12:28
a53414d to
dbc51a2
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Multiline text on iOS can shift outside its background or get clipped when using center or right alignment.
In one of my example.
When switching from left to right text alignment,
textBounds.origin.xchanged from 0 to 683.95, while self.size remained (853, 117). Drawing the container at the requested origin (663, 1911) therefore shifted the text horizontally.This PR subtract the text bounds origin before drawing glyphs and backgrounds. To counter the fact that
layoutManager.drawBackgroundandlayoutManager.drawGlyphsre-apply thetextBounds.origin.An additional UI manual test has been implemented (commit 6038e2a).
Showcasing the issue. You can checkout the commit and test the example app for the repro.
Before

After

Validation