mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-14 10:01:08 +08:00
16 lines
513 B
TypeScript
16 lines
513 B
TypeScript
export const VALID_FONT_SCALES = __APPLE__ // Apple supports a wider number of font scales than Android does.
|
|
? [0.5, 0.7, 0.85, 1, 1.15, 1.3, 1.5, 2, 2.5, 3, 3.5, 4]
|
|
: [0.85, 1, 1.15, 1.3];
|
|
|
|
export function getClosestValidFontScale(fontScale: number): number {
|
|
fontScale = Number(fontScale) || 1;
|
|
|
|
return VALID_FONT_SCALES.sort((a, b) => Math.abs(fontScale - a) - Math.abs(fontScale - b))[0];
|
|
}
|
|
|
|
export enum FontScaleCategory {
|
|
ExtraSmall = 'extra-small',
|
|
Medium = 'medium',
|
|
ExtraLarge = 'extra-large',
|
|
}
|