Repository navigation
Measure text at the window's density on Android (#59087) - #59087
Closed
brunocramos wants to merge 1 commit into
Closed
brunocramos wants to merge 1 commit into
brunocramos wants to merge 1 commit into
Conversation
|
@brunocramos has exported this pull request. If you are a Meta employee, you can view the originating Diff in D123975873. |
brunocramos
pushed a commit
to brunocramos/react-native
that referenced
this pull request
Oct 14, 2026
Summary: `DisplayMetricsHolder.initDisplayMetrics()` takes `density` and `densityDpi` from `Display.getRealMetrics()`, the physical display, but `scaledDensity` from the window's configuration. When a window renders at a different density than its display, text is measured at one density and laid out at the other, so it comes out clipped or oversized. With the new `useWindowDensityForDisplayMetricsAndroid` feature flag on, the screen metrics keep the window's `density` and `densityDpi` and take only the screen size from the display. The flag is off by default, so nothing changes for apps that don't turn it on. `initDisplayMetrics` reads the flag only when the window's density differs from the display's, so in the usual case it doesn't touch feature flags, and apps can still set their flags after calling it. **How to use:** return `true` from your app's feature flag overrides, before React Native starts: ``` override fun useWindowDensityForDisplayMetricsAndroid(): Boolean = true ``` Changelog: [Internal] Reviewed By: javache Differential Revision: D123975873
brunocramos
force-pushed
the
export-D123975873
branch
from
October 14, 2026 18:06
1c29c65 to
db7566e
Compare
Summary: `DisplayMetricsHolder.initDisplayMetrics()` takes `density` and `densityDpi` from `Display.getRealMetrics()`, the physical display, but `scaledDensity` from the window's configuration. When a window renders at a different density than its display, text is measured at one density and laid out at the other, so it comes out clipped or oversized. With the new `useWindowDensityForDisplayMetricsAndroid` feature flag on, the screen metrics keep the window's `density` and `densityDpi` and take only the screen size from the display. The flag is off by default, so nothing changes for apps that don't turn it on. `initDisplayMetrics` reads the flag only when the window's density differs from the display's, so in the usual case it doesn't touch feature flags, and apps can still set their flags after calling it. **How to use:** return `true` from your app's feature flag overrides, before React Native starts: ``` override fun useWindowDensityForDisplayMetricsAndroid(): Boolean = true ``` Changelog: [Internal] Reviewed By: javache Differential Revision: D123975873
brunocramos
force-pushed
the
export-D123975873
branch
from
October 14, 2026 18:54
db7566e to
9044e09
Compare
|
This pull request has been merged in 43c9b88. |
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:
DisplayMetricsHolder.initDisplayMetrics()takesdensityanddensityDpifromDisplay.getRealMetrics(), the physical display, butscaledDensityfrom the window's configuration. When a window renders at a different density than its display, text is measured at one density and laid out at the other, so it comes out clipped or oversized.With the new
useWindowDensityForDisplayMetricsAndroidfeature flag on, the screen metrics keep the window'sdensityanddensityDpiand take only the screen size from the display. The flag is off by default, so nothing changes for apps that don't turn it on.initDisplayMetricsreads the flag only when the window's density differs from the display's, so in the usual case it doesn't touch feature flags, and apps can still set their flags after calling it.How to use: return
truefrom your app's feature flag overrides, before React Native starts:Changelog:
[Internal]
Reviewed By: javache
Differential Revision: D123975873