Repository navigation
Commit 7b6516e
Keep mixed-direction text on screen with Android 15 start overhang (#59167)
Summary:
Pull Request resolved: #59167
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+
Reviewed By: Abbondanzo
Differential Revision: D125908523
fbshipit-source-id: 9955f447b3ab0eda603ce88971d1dab59eddb9d11 parent ad2f451 commit 7b6516e
2 files changed
Lines changed: 59 additions & 1 deletion
File tree
- packages/react-native/ReactAndroid/src
- main/java/com/facebook/react/views/text
- test/java/com/facebook/react/views/text
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
913 | 913 | | |
914 | 914 | | |
915 | 915 | | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
916 | 934 | | |
917 | 935 | | |
918 | 936 | | |
| |||
950 | 968 | | |
951 | 969 | | |
952 | 970 | | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
953 | 980 | | |
954 | 981 | | |
955 | 982 | | |
| |||
979 | 1006 | | |
980 | 1007 | | |
981 | 1008 | | |
| 1009 | + | |
982 | 1010 | | |
983 | 1011 | | |
984 | 1012 | | |
| |||
1005 | 1033 | | |
1006 | 1034 | | |
1007 | 1035 | | |
1008 | | - | |
| 1036 | + | |
1009 | 1037 | | |
1010 | 1038 | | |
1011 | 1039 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
118 | 148 | | |
119 | 149 | | |
120 | 150 | | |
| |||
0 commit comments