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:
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?
sans-serif-light
and Roboto
are Android-only fonts. You need different fonts for iOS. This repository has a list of fonts available for iOS and Android - https://github.com/react-native-training/react-native-fonts
You can use Platform.select()
to target different fonts for each OS:
title: {
...Platform.select({
ios: { fontFamily: 'Arial', },
android: { fontFamily: 'Roboto' }
})
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With