Commit 7e02fc7
Remove the unused
Summary:
Fabric's `ParagraphAttributes` carries a `maximumFontSize` field, but it is not exposed by the `<Text>` or `<TextInput>` APIs, so normal JS usage leaves it as `NaN`. On iOS, `RCTTextLayoutManager` falls back to a 96pt maximum when it is `NaN`. On Android, the C++ side serializes it into MapBuffer key 7, but `TextLayoutManager` never reads that key.
This PR removes the attribute: the `ParagraphAttributes` field, its raw-prop parsing in `conversions.h`, the paragraph and text input prop entries, and MapBuffer key 7 on both the C++ and Kotlin sides.
- **iOS**: `RCTTextLayoutManager` now passes the largest font size in the attributed string to `scaleFontSizeToFitSize:` as the maximum instead of 96pt. `scaleFontSizeToFitSize:` returns early when the text already fits; otherwise `scaleFontSizeWithRatio:` applies `MIN(pointSize * ratio, maximumFontSize)` on each pass of a bisection over the ratio. With 96pt, fonts above 96pt were clamped to 96pt on every pass, and when that clamp alone made the text fit, the search went on to ratios above 1.0 and grew the remaining fonts up to 96pt. With the largest font size as the maximum the clamp is a no-op, the ratio-1.0 pass reproduces the original text, which is known not to fit, and every later pass shrinks. Fonts above 96pt are now scaled proportionally rather than capped, and text is never grown. Text at 96pt or smaller is unaffected.
- **Android**: `PA_KEY_MAXIMUM_FONT_SIZE` is removed. Nothing reads it, so there is no behavior change.
Split out of #58492. #58492 builds on this and reuses the largest-font-size helper for `minimumFontScale`.
## Changelog:
[GENERAL] [REMOVED] - Remove the unused `maximumFontSize` paragraph attribute
Pull Request resolved: #58529
Test Plan:
**Unit tests**
- Updated `ParagraphAttributesTest.cpp` for the removed field.
- Regenerated the C++ API snapshots (`yarn cxx-api-build`).
```sh
./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests 'com.facebook.react.views.text.*'
```
All 38 `com.facebook.react.views.text` tests pass.
Reviewed By: cipolleschi
Differential Revision: D120127100
Pulled By: javache
fbshipit-source-id: 44e7de2c21c95500e721d5c6f4b4e207da369713maximumFontSize paragraph attribute (#58529)1 parent b9adf95 commit 7e02fc7
19 files changed
Lines changed: 21 additions & 60 deletions
File tree
- packages/react-native
- ReactAndroid/src/main/java/com/facebook/react/views/text
- ReactCommon/react/renderer
- attributedstring
- tests
- components
- textinput
- platform/android/react/renderer/components/androidtextinput
- text
- platform/android/react/renderer/components/text
- textlayoutmanager/platform/ios/react/renderer/textlayoutmanager
- scripts/cxx-api/api-snapshots
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
98 | 97 | | |
99 | 98 | | |
100 | 99 | | |
| |||
Lines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
| |||
64 | 63 | | |
65 | 64 | | |
66 | 65 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | 66 | | |
72 | 67 | | |
73 | 68 | | |
| |||
Lines changed: 1 addition & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
72 | | - | |
| 71 | + | |
73 | 72 | | |
74 | 73 | | |
75 | | - | |
76 | 74 | | |
77 | 75 | | |
78 | 76 | | |
| |||
110 | 108 | | |
111 | 109 | | |
112 | 110 | | |
113 | | - | |
114 | 111 | | |
115 | 112 | | |
116 | 113 | | |
| |||
Lines changed: 0 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1091 | 1091 | | |
1092 | 1092 | | |
1093 | 1093 | | |
1094 | | - | |
1095 | | - | |
1096 | | - | |
1097 | | - | |
1098 | | - | |
1099 | | - | |
1100 | 1094 | | |
1101 | 1095 | | |
1102 | 1096 | | |
| |||
1200 | 1194 | | |
1201 | 1195 | | |
1202 | 1196 | | |
1203 | | - | |
1204 | 1197 | | |
1205 | 1198 | | |
1206 | 1199 | | |
| |||
1218 | 1211 | | |
1219 | 1212 | | |
1220 | 1213 | | |
1221 | | - | |
1222 | 1214 | | |
1223 | 1215 | | |
1224 | 1216 | | |
| |||
Lines changed: 3 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
39 | | - | |
40 | 38 | | |
41 | 39 | | |
42 | 40 | | |
| |||
46 | 44 | | |
47 | 45 | | |
48 | 46 | | |
49 | | - | |
50 | | - | |
| 47 | + | |
| 48 | + | |
51 | 49 | | |
52 | 50 | | |
53 | 51 | | |
| |||
Lines changed: 0 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | 107 | | |
114 | 108 | | |
115 | 109 | | |
| |||
Lines changed: 0 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | 131 | | |
138 | 132 | | |
139 | 133 | | |
| |||
Lines changed: 0 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | 182 | | |
189 | 183 | | |
190 | 184 | | |
| |||
Lines changed: 0 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | 398 | | |
405 | 399 | | |
406 | 400 | | |
| |||
Lines changed: 17 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
418 | 434 | | |
419 | 435 | | |
420 | 436 | | |
| |||
439 | 455 | | |
440 | 456 | | |
441 | 457 | | |
442 | | - | |
| 458 | + | |
443 | 459 | | |
444 | 460 | | |
445 | 461 | | |
| |||
0 commit comments