Using custom fonts in react native with font family name instead of file name

Viewed 18

Problem:

I have font separated to 2 files, like "XSansRegular.ttf" and "XSansBold.ttf", both has same font family, like "X Sans".

I have added it as assets.

But when I'm trying to use them with setting:

style={{
    fontFamily: "X Sans"
}}

it doesn't work. I need to use exact file name, like this:

style={{
    fontFamily: "XSansRegular"
}}

What I want to do:

Use it with font name, instead of file name

style={{
    fontFamily: "X Sans"
}}

with possibility to pass there props like bold

style={{
    fontFamily: "X Sans",
    fontWeight: 'bold'
}}
0 Answers
Related