DEV Community

Cover image for Add Custom Fonts in React Native 0.63 for iOS and android
Aneeqa Khan
Aneeqa Khan

Posted on • Edited on

Add Custom Fonts in React Native 0.63 for iOS and android

Adding Custom Fonts to React Native App is quite easy and only needs a few steps. I am writing down the steps I did to add custom fonts to my app.

Download Google Font

First, you need to download your desired fonts from google fonts.

Add fonts to app folder

Create a fonts folder in your src/assets folder on root directory level and paste downloaded fonts files in it.

fonts folder

Export fonts

Now create a file named react-native.config.js at the root of your app and add the path of fonts folder like this



module.exports = {
   assets: ['./src/assets/fonts'],
};


Enter fullscreen mode Exit fullscreen mode

Link assets to project

After adding this, run link command in your project folder.



npx react-native link


Enter fullscreen mode Exit fullscreen mode

Link command will add font files into assets folder in the android folder of your app and to info.plist file in the iOS folder.

Add resources to target

Now at this point, your custom fonts will start working for the android app but you need to do one last step to make it work for iOS.

Go to the desired target of your app in Xcode, select the Build Phases tab, and add font files in the "Copy Bundle Resources" tab as shown below.

Alt Text

And you are done! 🎉 🎊

You are welcome to share your thoughts in comments

Oldest comments (28)

Collapse
 
nxtsuki profile image
nxtsuki

Very nice thread, worked for me!

Collapse
 
aneeqakhan profile image
Aneeqa Khan

Thank you!

Collapse
 
mango3ree profile image
Vlad

Thanks!Working

Collapse
 
aneeqakhan profile image
Aneeqa Khan

Glad to hear this :)

Collapse
 
hamidehdl profile image
Hamideh

Short and useful, thank you.

Collapse
 
aneeqakhan profile image
Aneeqa Khan

thank you! :)

Collapse
 
256hz profile image
Abe Dolinger • Edited

Very helpful thanks! Using RN 0.63.3, it looks like the XCode step is done for us at the linking step. Just have to remember to rebuild the app after.

Collapse
 
aneeqakhan profile image
Aneeqa Khan

Thanks!

Collapse
 
obkurucu_ profile image
ozankurucu

Thanks.

Collapse
 
muhsarip profile image
muhsarip

how about setup that font on android? should i setup via xcode too?

Collapse
 
enestatli profile image
enestatli

npx react-native link is enough for Android. XCode is a development environment for macOS used to develop iOS.

Collapse
 
dayrimax91 profile image
Dayri Garcia Brito

Me funcionó. Muchas gracias.

Collapse
 
kulsoom1 profile image
Kulsoom-1

This helps, thanks! But I guess linking is doing the ios part for us as well so no need to add font files in Build Phases.

Collapse
 
aneeqakhan profile image
Aneeqa Khan

ahan. Thats great then

Collapse
 
dzulfahmi profile image
Fitra Zul Fahmi

Thanks

Collapse
 
cs1881 profile image
Charles

Nice concise for quick reminding ourselves the steps.

Collapse
 
das2108 profile image
DAS2108

Hi Aneeqa,
I Cant find Build Phase like your screencap in my xcode.
Could you please tell me, where I can find it?

Collapse
 
aneeqakhan profile image
Aneeqa Khan

you have to go into your project folder first in xCode then select your app target and there you will top tabs for "General", "Build Phases",... settings.