Remove the unused maximumFontSize paragraph attribute - #58529
Open
conner1reimers wants to merge 1 commit into
Open
conner1reimers wants to merge 1 commit into
conner1reimers wants to merge 1 commit into
Conversation
maximumFontSize paragraph attribute
|
@javache has imported this pull request. If you are a Meta employee, you can view this in D120127100. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Fabric's
ParagraphAttributescarries amaximumFontSizefield, but it is not exposed by the<Text>or<TextInput>APIs, so normal JS usage leaves it asNaN. On iOS,RCTTextLayoutManagerfalls back to a 96pt maximum when it isNaN. On Android, the C++ side serializes it into MapBuffer key 7, butTextLayoutManagernever reads that key.This PR removes the attribute: the
ParagraphAttributesfield, its raw-prop parsing inconversions.h, the paragraph and text input prop entries, and MapBuffer key 7 on both the C++ and Kotlin sides.RCTTextLayoutManagernow passes the largest font size in the attributed string toscaleFontSizeToFitSize:as the maximum instead of 96pt.scaleFontSizeToFitSize:returns early when the text already fits; otherwisescaleFontSizeWithRatio:appliesMIN(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.PA_KEY_MAXIMUM_FONT_SIZEis 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
maximumFontSizeparagraph attributeTest Plan:
Unit tests
ParagraphAttributesTest.cppfor the removed field.yarn cxx-api-build)../gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests 'com.facebook.react.views.text.*'All 38
com.facebook.react.views.texttests pass.