Skip to content

Fix RTL start overhang clipping on Android 15+ - #58072

Open
ngocdevv wants to merge 1 commit into
react:mainfrom
ngocdevv:codex/fix-android-rtl-start-overhang
Open

Fix RTL start overhang clipping on Android 15+#58072
ngocdevv wants to merge 1 commit into
react:mainfrom
ngocdevv:codex/fix-android-rtl-start-overhang

Conversation

@ngocdevv

Copy link
Copy Markdown

Summary:

Fixes #58064.

Android 15 added glyph-bounds APIs for StaticLayout, but Layout.draw() only shifts drawing when ink extends past the left edge. In an exactly constrained RTL paragraph, leading ink extends past the right edge instead, so fonts such as Amiri still clip their first glyph at a wrapped line start.

This change:

  • enables setUseBoundsForWidth and setShiftDrawingOffsetForStartOverhang for exactly constrained StaticLayouts on API 35+ using the existing reflection approach;
  • measures the actual RTL drawing bounds and reserves any right-side overhang in a focused second layout pass while keeping the original exact width reported to Yoga;
  • leaves AT_MOST and unconstrained text on the existing advance-based measurement path.

On the issue reproducer, the first layout was 1280 px wide while its glyph bounds extended to x=1287.07. Reserving 8 px in the text layout keeps the complete alif-madda ink inside the unchanged 1280 px React Native view.

Changelog:

[ANDROID] [FIXED] - Prevent RTL line-start glyph ink from clipping on Android 15 and later

Test Plan:

  • JAVA_HOME=$(/usr/libexec/java_home -v 17) ./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests com.facebook.react.views.text.TextLayoutManagerStartOverhangTest -Preact.internal.useHermesStable=true --no-daemon — BUILD SUCCESSFUL
  • JAVA_HOME=$(/usr/libexec/java_home -v 17) ./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests 'com.facebook.react.views.text.*' -Preact.internal.useHermesStable=true --no-daemon — BUILD SUCCESSFUL
  • JAVA_HOME=$(/usr/libexec/java_home -v 17) ./gradlew :packages:react-native:ReactAndroid:ktfmtCheck -Preact.internal.useHermesStable=true --no-daemon --rerun-tasks — BUILD SUCCESSFUL
  • Built and installed RNTester on a Pixel 9 Pro emulator running Android 16 / API 36 with enablePreparedTextLayout enabled and the Amiri font from the mandatory reproducer. Before the fix, ink reached and was cut at the final pixel column; after the fix, the complete stroke renders inside the tinted Text bounds.

@meta-cla

meta-cla Bot commented Aug 22, 2026

Copy link
Copy Markdown

Hi @ngocdevv!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 22, 2026
@meta-cla

meta-cla Bot commented Aug 22, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

1 participant