How to add custom font in react native android

后端 未结 13 1243
别那么骄傲
别那么骄傲 2020-12-01 12:28

I am learning react-native, trying to create some demo apps just for learning. I want to set fontFamily to roboto thin of my toolbar title.

<
13条回答
  •  春和景丽
    2020-12-01 13:05

    Put all your fonts in you React-Native project directory

    ./assets/fonts/
    

    Add the following line in your package.json

    "rnpm": {
      "assets": ["./assets/fonts"]
    }
    

    finally run in the terminal from your project directory

    $ react-native link
    

    to use it declare this way in your styles

    fontFamily: 'your-font-name without extension'
    

    If your font is Raleway-Bold.ttf then,

    fontFamily: 'Raleway-Bold'
    

提交回复
热议问题