@momo-kits/foundation 0.160.1-beta.3 → 0.160.1-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Text/utils.ts +10 -7
- package/package.json +1 -1
package/Text/utils.ts
CHANGED
|
@@ -10,16 +10,19 @@ const useScaleSize = (size: number) => {
|
|
|
10
10
|
const { width } = useWindowDimensions();
|
|
11
11
|
const context = useContext<any>(MiniAppContext);
|
|
12
12
|
const allowFontScale = context?.designSystemConfig?.allowFontScale ?? true;
|
|
13
|
-
if (!allowFontScale) return size;
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
if (allowFontScale) {
|
|
15
|
+
const deviceScale = width / DEFAULT_SCREEN_SIZE;
|
|
16
|
+
const fontScale = PixelRatio.getFontScale();
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const maxSize = size * MAX_FONT_SCALE;
|
|
19
|
+
const fontSizeScaleDevice = deviceScale > 1 ? deviceScale * size : size;
|
|
20
|
+
const fontSizeScaleOS = fontScale > 1 ? fontScale * size : size;
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
return Math.min(Math.max(fontSizeScaleDevice, fontSizeScaleOS), maxSize);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return size;
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
const scaleSize = (size: number) => {
|