Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fallback fonts in react native

Are there any current solutions for fallback fonts in react-native?

I have a font used throughout my application, but a specific character is not supported by this font. I would like it to fallback to a custom font (specifically for iOS) since it looks like the styling for this character changed from iOS 12 to iOS 13.

I see in the react native Text documentation that multiple fonts are not supported, but I'm wondering if there are any third party solutions for this.

EDIT: The font cannot be hard coded since this character may show up in any string. It must fall back at a high level text component used throughout the application.

Cheers!

like image 544
Taylor Johnson Avatar asked Dec 03 '25 03:12

Taylor Johnson


1 Answers

Basically, there is no way that React Native will automatically do that. You have to define your special character and tell RN to use your alternative fonts. There is a RN library to do that for you: React Native Hightlight Words. This component will detect your special character, and render it with your custom style (including your font)

like image 128
Minh Dao Avatar answered Dec 04 '25 16:12

Minh Dao