Skip to content

Keep mixed-direction text on screen with Android 15 start overhang - #59167

Open
fkgozali wants to merge 1 commit into
react:mainfrom
fkgozali:export-D125908523
Open

fkgozali wants to merge 1 commit into
react:mainfrom
fkgozali:export-D125908523

Conversation

@fkgozali

Copy link
Copy Markdown
Contributor

Summary:
On Android 15 and 16.0, Layout.computeDrawingBoundingBox() reuses a single RectF for every line and TextLine.metrics() does not reset it. A line whose paragraph direction is LTR, laid out after an RTL line, inherits the RTL line's bounds in RTL-relative (negative) coordinates. With setShiftDrawingOffsetForStartOverhang(true), Layout.draw() then translates the whole text right by about one line width, so the text disappears or only a few glyphs stay visible at the right edge.

Common RTL content hits this: a blank line between Arabic or Hebrew paragraphs has no strong character and is laid out LTR. The platform fixed it in a later Android 16 release by resetting the rect per line.

When an exactly sized layout has mixed paragraph directions, rebuild it without the start-overhang drawing shift. Bounds-based line breaking is kept, so the measured line breaks are unchanged. Single-direction text keeps the existing start-overhang behavior.

Changelog:
[Android][Fixed] - Fix multi-paragraph RTL Text with blank or LTR lines being drawn off-screen on Android 15+

Differential Revision: D125908523

Summary:
On Android 15 and 16.0, `Layout.computeDrawingBoundingBox()` reuses a single `RectF` for every line and `TextLine.metrics()` does not reset it. A line whose paragraph direction is LTR, laid out after an RTL line, inherits the RTL line's bounds in RTL-relative (negative) coordinates. With `setShiftDrawingOffsetForStartOverhang(true)`, `Layout.draw()` then translates the whole text right by about one line width, so the text disappears or only a few glyphs stay visible at the right edge.

Common RTL content hits this: a blank line between Arabic or Hebrew paragraphs has no strong character and is laid out LTR. The platform fixed it in a later Android 16 release by resetting the rect per line.

When an exactly sized layout has mixed paragraph directions, rebuild it without the start-overhang drawing shift. Bounds-based line breaking is kept, so the measured line breaks are unchanged. Single-direction text keeps the existing start-overhang behavior.

Changelog:
[Android][Fixed] - Fix multi-paragraph RTL `Text` with blank or LTR lines being drawn off-screen on Android 15+

Differential Revision: D125908523
@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 Oct 18, 2026
@meta-codesync

meta-codesync Bot commented Oct 18, 2026

Copy link
Copy Markdown

@fkgozali has exported this pull request. If you are a Meta employee, you can view the originating Diff in D125908523.

This branch has not been deployed

No deployments
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. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant