TASIOMIND.DEV — OPERATIONAL▸▸▸FULL STACK DEVELOPER @ GWQ SERVICEPLUS AG▸▸▸FOUNDER — K8SGPT.AI▸▸▸OPEN SOURCE: ACTIVE▸▸▸DISTRIBUTED SYSTEMS / KUBERNETES / AI▸▸▸RUST + GO + PYTHON▸▸▸FIELD TESTED / STATUS — NOMINAL▸▸▸LOCATION: EUROPE/BERLIN▸▸▸TASIOMIND.DEV — OPERATIONAL▸▸▸FULL STACK DEVELOPER @ GWQ SERVICEPLUS AG▸▸▸FOUNDER — K8SGPT.AI▸▸▸OPEN SOURCE: ACTIVE▸▸▸DISTRIBUTED SYSTEMS / KUBERNETES / AI▸▸▸RUST + GO + PYTHON▸▸▸FIELD TESTED / STATUS — NOMINAL▸▸▸LOCATION: EUROPE/BERLIN▸▸▸

Custom fonts in React Native

August 3, 2020

tl;dr

  1. Create an assets folder and copy your fonts to it
  2. Add config to react-native.config.js
  3. Run react-native link to install fonts for both Android and iOS
code
// react-native.config.js
module.exports = {
  assets: ["./assets/fonts/Graphik"],
};
code
android/app/src/main/assets/

The value for fotFamily (or just font-family if you're usig styled-components) will be the font filename minus the extension.

Notes of font formats

Use .otf or .ttf.

.woff won't work. (.woff is a compressed version of OpenType .otf or TrueType .ttf)

Troubleshooting

code
error Linking assets failed. Run CLI with --verbose flag for more details.
SyntaxError: Expected [\n\r] but end of input found.

Add a new line at the end of ios/[Project].xcodeproj/project.pbxproj and run react-native link again