-
Notifications
You must be signed in to change notification settings - Fork 8
/
App.js
32 lines (29 loc) · 957 Bytes
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React from "react";
import PropTypes from "prop-types";
import {View, StyleSheet, Text} from "react-native";
import CustomFontsProvider, { useCustomFont } from "react-native-custom-fonts";
const fontFaces = {
// XXX: Specify the local name of your font. You'll use this to refer to it via the useCustomFont hook.
'UbuntuBold': {
uri: 'https://github.com/google/fonts/raw/master/ufl/ubuntu/Ubuntu-Bold.ttf',
fontFamily: 'Ubuntu',
fontWeight: 'bold',
// XXX: You can also specify additional font styling.
color: 'blue',
},
};
const SomeComponent = () => {
// Fetch the desired font by name. When the font has been cached, it will automatically update the View.
const {...fontProps} = useCustomFont('UbuntuBold');
return (
<Text
{...fontProps}
children="Hello, world!"
/>
);
};
export default () => (
<CustomFontsProvider fontFaces={fontFaces}>
<SomeComponent />
</CustomFontsProvider>
);