Adding custom fonts in React Native 0.60+ | React native | Android

Опубликовано: 06 Октябрь 2024
на канале: JAS ACADAMY
2,034
18

1. Get the font files needed for the project

The font files should be .ttf format. The font files can be obtained from Google fonts. Create a folder named fonts under the assets directory and place the font files in it.

2. Create a configuration file

Create a configuration file named react-native.config.js in the root project directory and add the following code

module.exports = {
project: {
ios:{},
android:{}
},
assets:['./assets/fonts/'],
}

3. Link the font assets
Link the newly added asset by running the following command:

npx react-native link