Document Android 14+ non-linear font scaling on getFontScale and allowFontScaling - #5205
Open
sbaiahmed1 wants to merge 1 commit into
Open
Document Android 14+ non-linear font scaling on getFontScale and allowFontScaling#5205sbaiahmed1 wants to merge 1 commit into
sbaiahmed1 wants to merge 1 commit into
Conversation
…wFontScaling On Android 14 and newer, the OS scales fonts non-linearly (small sizes grow by the full factor, large sizes progressively less; 30sp is pinned until the setting exceeds 1.5), so PixelRatio.getFontScale() no longer predicts rendered text sizes. Document this on the PixelRatio and Text pages for next and 0.86. Prompted by react/react-native#56961, where the non-linear curve was mistaken for a rendering bug.
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.
The
PixelRatio.getFontScale()docs currently tell readers the value "is used to calculate the absolute font size", and theallowFontScalingdocs imply a single scale factor. On Android 14 and newer that is no longer accurate: the OS applies non-linear font scaling once the user's font scale is ≥ 1.05 — small fonts grow by roughly the full factor while large fonts grow progressively less, and a 30sp font does not grow at all until the setting exceeds 1.5 (per AOSP'sFontScaleConverterFactorytables). React Native inherits this viaTypedValue.applyDimension(COMPLEX_UNIT_SP, …), sofontSize * getFontScale()overestimates rendered sizes of large text.This mismatch was mistaken for a rendering bug in react/react-native#56961 — I verified there that RN matches the platform tables exactly (measurements in this comment).
Changes:
docs/pixelratio.md: add a note undergetFontScale()explaining non-linear scaling and the caveat about multiplying by the returned value.docs/text.md: add one sentence underallowFontScaling.website/versioned_docs/version-0.86/.