木大白易
木大白易

Reputation: 692

How can we set a group of fonts using fontFamily props in React Native?

As in css , we can set like this :

font-family:"Times New Roman",Georgia,Serif;

But in RN , we can just set one font ,

fontFamily: 'MidPlane00v3.1',

How can we use it like css? I need to show multiple bytes Chinese words using font rollback mechanism!

Upvotes: 13

Views: 6498

Answers (1)

Luís Mestre
Luís Mestre

Reputation: 1938

You can't set font-family in react-native like you would in CSS. This is because in CSS what's happening is that the browser will try to fetch the first font-family and in case it can't it will try the next defined alternative, like stated in W3 Schools

In react-native, this isn't an issue because you'll add the font-family to the app's native assets folder, guarantying the font-family's presence on the app. If you want a further explanation on why, you can take a look at React Native documentation.

And if you want to know how to add custom font-family to the project, you can follow this guide

Upvotes: 1

Related Questions