Expo `.ttf` fonts don't load using SDK 42 and `expo-font@9.2.1`
See original GitHub issueSummary
Font loading doesn’t seem to work with .ttf
fonts. It used to… but trying to upgrade to the latest Expo SDK results in errors. There is more information in the reproduction repo below, code is identical to the documentation over here.
Managed or bare workflow? If you have ios/
or android/
directories in your project, the answer is bare!
managed
What platform(s) does this occur on?
iOS
SDK Version (managed workflow only)
42
Environment
Mac OS 11.4 Node 14 Latest expo (42)
Reproducible demo or steps to reproduce from a blank project
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:13 (4 by maintainers)
Top Results From Across the Web
Font
expo -font allows loading fonts from the web and using them in React Native components. See more detailed usage information in the Fonts...
Read more >React Native Expo - Custom Fonts Not Loading With Font. ...
Here is a fresh project I set up attempting to get a custom font installed. import React, { useState } from 'react'; import...
Read more >[Deprecated] Custom fonts in React Native (Expo)
To get started, download the font you want to use in your app in .ttf or .otf format. Create a directory in the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Im still having problem making this work. I can´t get any fonts or icons to load for ios
@dashcraft interesting, if this is happening in dev then it might be a metro.config.js / expo-cli issue – in production it’s probably an expo-updates update. I’m investigating it as a metro issue, and I’ve linked the issue to the updates team for them to check out as well.
Edit: cannot repro using the same specs here https://github.com/expo/expo/issues/13358#issuecomment-912818774 downgrading my expo-cli version to determine if this was fixed somehow.
Edit 2: I can repro the font issue using the font repro, thanks @hanford for providing it! Using yarn instead of npm install appears to fix the issue, gonna try and figure out why. Clearing the
package-lock.json
, and regenerating seems to also fix the issue. Possibly related to this dependency issue:Edit 3: Can confirm the duplicate copy of
expo-font
is the issue, not exactly sure how we can prevent this right now, both versions appear to be the same version (9.2.1) 🙃 I’d recommend usingyarn
to install packages as it works better thannpm install
. Nuking the package-lock.json and reinstalling withnpm install
also worked, but it’s unclear why it only worked this time and not before since the versions didn’t change.