Easy way for text component to apply custom remote font.
Just tell the component the font's name and url.
- No need to worry about font's download, cache, load.
- No need to worry about complicated logic when switching fonts.
$ npm install react-native-remote-font --save
$ react-native link react-native-remote-font
import ArtText from "react-native-remote-font";
<ArtText
text="Hello World"
style={{ fontSize: 20 }}
fontInfo={{
fontName: "Afacad",
fontUrl: "https://fonts.gstatic.com/s/afacad/v1/6NUI8FKMIQOGaw6ahLYEvBjUVG5Ga92uVSQ-9kKlZfNfuw.ttf",
}}
/>
Passthrough the properties of all Text components, such as text, style, etc.
Prop | Type | Default | Description |
---|---|---|---|
fontInfo.fontName | string | Font name | |
fontInfo.fontUrl | string | Font download web url |
-
android
$ cd example && yarn && yarn start && yarn android
-
ios
$ cd example && yarn && yarn start && yarn ios
If you meet some error like package link, try to find the solution here https://zyestin.github.io/create-npm-lib/#%E8%BF%90%E8%A1%8C-android%E6%8C%BA%E5%9D%91
MIT