How to add custom font in react native android

后端 未结 13 1250
别那么骄傲
别那么骄傲 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:12

    UPDATE

    Many answers are here for adding custom font in react-native for version < 0.60.

    For those who are using react-native version > 0.60 , 'rnpm' is deprecated and custom fonts will not work.

    Now, in order to add custom font in react-native version > 0.60 you will have to :

    1- Create a file named react-native.config.js in the root folder of your project.

    2- add this in that new file

    module.exports = {
    project: {
        ios: {},
        android: {},
    },
    assets: ['./assets/fonts']
    };
    

    3- run react-native link command in the root project path.

    PS Make sure you have the right path for the fonts folder before running react-native link command

提交回复
热议问题