I thought the configuration of custom font is not a big hole, the official website document to find, there is no. React Native configures custom fonts. Are the same article, the author name is all kinds of, is really the world article everyone copy. But try it and it doesn’t work.

(The latest RN 0.48.4 test is used here)

Here’s how React Native’s latest, easiest way to configure custom fonts: 1) Download any font (don’t change the name, it’s scratchmyback) and I’ve created a scratchmyback English font here. SCRATCHMYBACK.TTF

2) Create folder Assets /fonts in the project root directory. And put in the font that you just downloaded.

3) Tell React Native where our custom font is in package. json:

"rnpm": {
    "assets": [
	"./assets/fonts/"
    ]
}Copy the code

4) React-native Link (no need to manually open Xcode, copy folder into project)

5) IOS needs to add custom fonts to the info.plist file to use:

<key>UIAppFonts</key>
<array>
   <string>SCRATCHMYBACK.TTF</string>
</array>Copy the code

Android link operation automatically is introduced into the font copy to the Android/app/SRC/main/assets/fonts/folder. Just make sure.

6) You can now use custom fonts in the censer via fontFamily. Recompile and you’re done