React Native Cookbook
上QQ阅读APP看书,第一时间看更新

Getting ready

In order to work on this example we need some fonts. You can use whatever fonts you want. I recommend going to Google Fonts (https://fonts.google.com/) and downloading your favorites. For this recipe, we will be using the Josefin Sans and Raleway fonts.

Once you have the fonts downloaded, let's create an empty app and name it custom-fonts.  When we create a blank app with Expo, it creates an assets folder in the root of the project for placing all of your assets (images, fonts, and so on), so we'll follow the standard and add our fonts to this folder. Let's create the /assets/fonts folder and add our custom font files downloaded from Google Fonts.

When downloading fonts from Google Fonts, you'll get a .zip file containing a .ttf file for each of the font family variants.  We will be using the regular, bold, and italic variations, so copy the corresponding .ttf files for each variant in each family to our /assets/fonts folder.