textfontsreact-nativefont-familyroboto

Font family Roboto light and bold in react native


I',m making some changes to the text in my react native application: I need to specify Roboto light for paragraphs and Roboto Bold for titles. I need to have the same look of the text in both iOS and Android apps: so I need to make it work for both I tried this code line of code

text    : {
       fontFamily: 'sans-serif-light'
   }, 

but I get this error: enter image description here

I tried this type from the official documentation and it's working fine

title   : {
       fontFamily: 'Cochin'
   },

--> So I think the problem is in the Roboto font family itself. Any help?


Solution

  • To add custom fonts to your app store all your ttf files in a directory. Add the following code to your package.json file.

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

    Then run react-native link To use the font use the same name on the ttf file in fontFamily.