0
votes

I have been desperate for 2 days. I am trying to use custom fonts in my React Native application. I have followed many tutorials, but nothing works.

I have: - import my fonts into the "root/assets/fonts" folder (image 1) enter image description here

  • create a react-native.config.js file (image 2) enter image description here

  • run "react-native link"

  • I also checked that the name of the font was correct.

But I still get this error message:

fontFamily "Gilroy-Regular" is not a system font and has not been loaded through Font.loadAsync.
- If you intended to use a system font, make sure you typed the name correctly and that it is supported by your device operating system.
- If this is a custom font, be sure to load it with Font.loadAsync.

Amazing fact: when I build the app on xcode directly, I don't get an error message and the fonts are well used.

This error occurs when I build with expo.

Thank you a lot for your help..

1

1 Answers

1
votes
import { Font } from 'expo'

componentDidMount() {
  Font.loadAsync({
  'Roboto': require('../assets/fonts/Roboto-Regular.ttf'),
})  
}