Skip to content

Remove the unused maximumFontSize paragraph attribute - #58529

Open
conner1reimers wants to merge 1 commit into
react:mainfrom
conner-reimers:remove-maximum-font-size
Open

conner1reimers wants to merge 1 commit into
react:mainfrom
conner-reimers:remove-maximum-font-size

Conversation

@conner1reimers

Copy link
Copy Markdown

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

Test Plan:

Unit tests

  • Updated ParagraphAttributesTest.cpp for the removed field.
  • Regenerated the C++ API snapshots (yarn cxx-api-build).
./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests 'com.facebook.react.views.text.*'

All 38 com.facebook.react.views.text tests pass.

@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 Sep 14, 2026
@conner1reimers conner1reimers changed the title Remove the unused maximumFontSize paragraph attribute Remove the unused maximumFontSize paragraph attribute Sep 14, 2026
@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 Sep 15, 2026
@meta-codesync

meta-codesync Bot commented Sep 15, 2026

Copy link
Copy Markdown

@javache has imported this pull request. If you are a Meta employee, you can view this in D120127100.

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

Development

Successfully merging this pull request may close these issues.

1 participant