If you are using expo, after this steps it should work:
step 1:
put you Lobster-Regular.ttf file inside ./assets/fonts
step 2:
Your file should be similar to this:
import React, { Component } from 'react'
import { Text, View} from 'react-native'
import * as Font from 'expo-font';
export default class App extends Component {
constructor(){
super();
this.state = {
fontLoaded: false
};
}
async componentDidMount(){
await Font.loadAsync({
'Lobster-Regular': require('./assets/fonts/Lobster-Regular.ttf'),
});
this.setState({ fontLoaded: true});
}
render() {
return (
<View>
{this.state.fontLoaded ?
<Text style={{fontFamily: 'Lobster-Regular'}}>hello everyone</Text>
: <Text>not loaded</Text>
}
</View>
)
}
}
If you are using a bare react-native and the linking does not work maybe you should do it manually.
For android:
In your android/app/src/main folder structure you will create an assets
folder with the fonts
folder inside. In the fonts folder you will place your font files here.
For iOS the steps are a little bit longer you can follow this blog