Repository navigation
Commit 92d6d0b
Keep mixed-direction text on screen with Android 15 start overhang
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: D1259085231 parent 27e7721 commit 92d6d0b
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 | |
|---|---|---|---|
| |||
903 | 903 | | |
904 | 904 | | |
905 | 905 | | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
906 | 924 | | |
907 | 925 | | |
908 | 926 | | |
| |||
940 | 958 | | |
941 | 959 | | |
942 | 960 | | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
943 | 970 | | |
944 | 971 | | |
945 | 972 | | |
| |||
969 | 996 | | |
970 | 997 | | |
971 | 998 | | |
| 999 | + | |
972 | 1000 | | |
973 | 1001 | | |
974 | 1002 | | |
| |||
995 | 1023 | | |
996 | 1024 | | |
997 | 1025 | | |
998 | | - | |
| 1026 | + | |
999 | 1027 | | |
1000 | 1028 | | |
1001 | 1029 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 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 | + | |
| 148 | + | |
119 | 149 | | |
120 | 150 | | |
121 | 151 | | |
| |||
0 commit comments