Agent86
Agent86

Reputation: 424

React-native custom font file naming

Is it possible to name the custom font files such that Android will automatically find the right one based on the style provided?

I am using custom font with styled components and this seems to work fine on iOS but not on Android:

font-family: 'myCustomFont';
font-weight: bold;

This picks myCustomFont-Bold on iOS but for android it picks a default font since it cannot find the font. I have to say this on Android:

font-family: 'myCustomFont-Bold';

Hoping there is a way so we can use the font across platforms without having to change the font-family for bold or italic, etc.

Upvotes: 0

Views: 1774

Answers (1)

Agent86
Agent86

Reputation: 424

For anyone else that stumbles on to here. This is the way to do it: https://github.com/jsamr/react-native-font-demo

This other approach gets you most of the way there but not quite as good as the previous response: How can i use same custom fonts for both android and ios using react native

Upvotes: 1

Related Questions