Fix text not scaling down when system fontScale < 1.0 #54238
Closed
+212
−0
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:
Fixes #54168
In React Native 0.82.0, text on Android does not scale down when the system font scale is set to less than 1.0 (e.g., 85%). This regression was introduced when
PixelUtil.toPixelFromSP()was changed to useDisplayMetricsHolder.getScreenDisplayMetrics()instead ofgetWindowDisplayMetrics()in commit 1ad2ec09.The issue occurs because:
context.resources.displayMetricsand includes the system font scale fromConfigurationDisplay.getRealMetrics(), which returns physical display metrics without the system font scale setting (Reference)When
getRealMetrics()is called, it overwrites thescaledDensityvalue (which isdensity * fontScale), effectively resetting it to justdensityand losing the user's font scale preference.Changelog:
[ANDROID] [FIXED] - Fix text not scaling down when system fontScale < 1.0
Test Plan:
https://github.com/kdwkr/rn-0.82.0-android-layout-scale
Tested with this reproducer