Taylor Johnson
Taylor Johnson

Reputation: 1953

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!

Upvotes: 3

Views: 1316

Answers (1)

Minh Dao
Minh Dao

Reputation: 837

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)

Upvotes: 1

Related Questions