@momo-kits/foundation 0.162.2-test.8 → 0.162.2-test.9
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 +11 -5
- package/package.json +1 -1
package/Text/utils.ts
CHANGED
|
@@ -16,10 +16,16 @@ const useScaleSize = (size: number, userScaleRate?: number) => {
|
|
|
16
16
|
|
|
17
17
|
// user-adjusted rate: param override > config > 1 (no scaling)
|
|
18
18
|
const customRate = userScaleRate ?? ctxRate ?? 1;
|
|
19
|
-
// useOSFontScale on -> apply the OS scale, ignore the custom rate;
|
|
20
|
-
// off -> use the custom rate. Both hard-capped at MAX_FONT_SCALE (150%).
|
|
21
|
-
const appliedRate = useOSFontScale ? fontScale : customRate;
|
|
22
19
|
|
|
20
|
+
// useOSFontScale off -> the user has full control via customRate; skip device-width scaling
|
|
21
|
+
// entirely and apply only the custom rate (capped at MAX_FONT_SCALE).
|
|
22
|
+
if (!useOSFontScale) {
|
|
23
|
+
return customRate > 1
|
|
24
|
+
? Math.min(customRate * size, size * MAX_FONT_SCALE)
|
|
25
|
+
: size;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// useOSFontScale on -> device-width scale + OS font scale, take the larger.
|
|
23
29
|
let fontSizeDeviceScale = size;
|
|
24
30
|
let fontSizeOSScale = size;
|
|
25
31
|
|
|
@@ -30,9 +36,9 @@ const useScaleSize = (size: number, userScaleRate?: number) => {
|
|
|
30
36
|
);
|
|
31
37
|
}
|
|
32
38
|
|
|
33
|
-
if (
|
|
39
|
+
if (fontScale > 1) {
|
|
34
40
|
fontSizeOSScale = Math.min(
|
|
35
|
-
|
|
41
|
+
fontScale * fontSizeOSScale,
|
|
36
42
|
fontSizeOSScale * MAX_FONT_SCALE,
|
|
37
43
|
);
|
|
38
44
|
}
|