Part 3: Custom fonts in ReactNative

Lara Mo
2 min readDec 19, 2021

--

Simple tutorial to add custom fonts to your ReactNative project

Versions:

While this article is directed to Windows users who develop an Android application using ReactNative, here are the versions of some tools I used while writing this article:

Step 1: Download the font collection

Download the ZIP bundle of the font collection of your choice. Here is a good source to use: https://www.fontsquirrel.com/fonts/

Step 2: Import fonts to the project

Unzip the fonts folder and add the fonts you will be using in your project.
I store my fonts under src/assets/fonts
For a recommended project structure, visit part2 of this series.

Personally, I will be only using two .ttf files out of the whole bundle (Regular and Medium).

fonts I use in my current project

Step 2.1: Renaming fonts

Ok, so this step is a little odd. My articles are targeted for Android dev only as I don't own a Mac to test my code on XCode. However, I have courted a common issue at work we can avoid.

The following list shows most of the default fonts for android and ios:https://gist.github.com/cdm/bce25582f796c96236c3625adbcba36f. Notice how android has only a couple of fonts that are built-in. IOS on the other hand, has a bunch. To avoid “double linking”, we will rename our fonts to have the same name as ios.

However, the font I chose to use for this article isn't available on ios either. I will rename the font files just to appear a little nicer regardless.

renaming fonts

Step 3: Create a config file

Create a config file called react-native.config.js in the root of your project.
Reference the fonts.

Step 4: Almost there, linking
Let's link our assets.

npx react-native link

Step 5: Usage

Until the next article!

-LaraMo

--

--

Lara Mo
Lara Mo

Written by Lara Mo

Student @Concordia University | Front-end developer @Plusgrade Passionate about React, JS, CSS, HTML and coffee :) | Coding & coffee is my moto ☕👩‍💻

No responses yet