UNPKG

1.61 kBTypeScriptView Raw
1import { Platform, PlatformOSType } from 'react-native';
2import type { Fonts } from '../types';
3
4const fontConfig = {
5 web: {
6 regular: {
7 fontFamily: 'Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif',
8 fontWeight: '400' as '400',
9 },
10 medium: {
11 fontFamily: 'Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif',
12 fontWeight: '500' as '500',
13 },
14 light: {
15 fontFamily: 'Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif',
16 fontWeight: '300' as '300',
17 },
18 thin: {
19 fontFamily: 'Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif',
20 fontWeight: '100' as '100',
21 },
22 },
23 ios: {
24 regular: {
25 fontFamily: 'System',
26 fontWeight: '400' as '400',
27 },
28 medium: {
29 fontFamily: 'System',
30 fontWeight: '500' as '500',
31 },
32 light: {
33 fontFamily: 'System',
34 fontWeight: '300' as '300',
35 },
36 thin: {
37 fontFamily: 'System',
38 fontWeight: '100' as '100',
39 },
40 },
41 default: {
42 regular: {
43 fontFamily: 'sans-serif',
44 fontWeight: 'normal' as 'normal',
45 },
46 medium: {
47 fontFamily: 'sans-serif-medium',
48 fontWeight: 'normal' as 'normal',
49 },
50 light: {
51 fontFamily: 'sans-serif-light',
52 fontWeight: 'normal' as 'normal',
53 },
54 thin: {
55 fontFamily: 'sans-serif-thin',
56 fontWeight: 'normal' as 'normal',
57 },
58 },
59};
60
61export default function configureFonts(
62 config?: { [platform in PlatformOSType | 'default']?: Fonts }
63): Fonts {
64 const fonts = Platform.select({ ...fontConfig, ...config }) as Fonts;
65 return fonts;
66}