Expose fontScale to JS
This commit is contained in:
parent
57ce9fb11a
commit
2b4daf228d
|
@ -29,6 +29,7 @@ if (dimensions && dimensions.windowPhysicalPixels) {
|
|||
width: windowPhysicalPixels.width / windowPhysicalPixels.scale,
|
||||
height: windowPhysicalPixels.height / windowPhysicalPixels.scale,
|
||||
scale: windowPhysicalPixels.scale,
|
||||
fontScale: windowPhysicalPixels.fontScale,
|
||||
};
|
||||
|
||||
// delete so no callers rely on this existing
|
||||
|
|
|
@ -59,6 +59,20 @@ class PixelRatio {
|
|||
return Dimensions.get('window').scale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scaling factor for font sizes. This is the ratio that is used to calculate the
|
||||
* absolute font size, so any elements that heavily depend on that should use this to do
|
||||
* calculations.
|
||||
*
|
||||
* If a font scale is not set, this returns the device pixel ratio.
|
||||
*
|
||||
* Currently this is only implemented on Android and reflects the user preference set in
|
||||
* Settings > Display > Font size, on iOS it will always return the default pixel ratio.
|
||||
*/
|
||||
static getFontScale(): number {
|
||||
return Dimensions.get('window').fontScale || PixelRatio.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a layout size (dp) to pixel size (px).
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue