Open History to see the last commit
1import { requireOptionalNativeModule } from "expo";
2import { useCallback } from "react";
3import { Platform, useWindowDimensions } from "react-native";
4
5const nativeControls =
6 Platform.OS === "android"
7 ? requireOptionalNativeModule<{ scaledFontSize?: (size: number) => number }>("T3NativeControls")
8 : null;
9
10/** Custom text renderers need the same scaled size for glyphs and their layout geometry. */
11export function useSystemFontScale() {
12 const { fontScale } = useWindowDimensions();
13 return useCallback(
14 (size: number) => nativeControls?.scaledFontSize?.(size) ?? size * fontScale,
15 [fontScale],
16 );
17}