expo: fontFamily "material" is not a system font and has not been loaded through Font.loadAsynch.
🐛 Bug Report
Environment
Environment ** React Native version: “react-native”: “https://github.com/expo/react-native/archive/sdk-36.0.1.tar.gz”, REACT NATIVE PAPER VERSISON 3.6.0 EXPO SDK 36.0.2
System:
OS: macOS 10.15.4
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 13.12.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.4 - ~/.npm/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Xcode: 11.0/11A420a - /usr/bin/xcodebuild
npmPackages:
expo: ^36.0.2 => 36.0.2
react: ^16.13.1 => 16.13.1
react-native: https://github.com/expo/react-native/archive/sdk-36.0.1.tar.gz => 0.61.4
react-navigation: ^4.3.5 => 4.3.6
npmGlobalPackages:
expo-cli: 3.16.1
Expo Client on iOS device
Steps to Reproduce
- Upgrade to latest version of Expo SDK (36.0.2)
- Add react-native-paper to project
- Make a sample screen
- Load custom fonts if needed
Expected Behavior
It should work and not complain about third party fonts which are located in node_modules. It should use custsom font when used with Font.loadAsynch()
Actual Behavior
I receive the following
fontFamily "material" is not a system font and has not been loaded through Font.loadAsync.
It’s not my font and probably a third party font which is bundled in expo’s module. See below.
Step I have undertaking:
-
Restarting pc
-
Removing cach, node_modules etc and reinstall everything
-
Try to link to the node modules font and load it in expo’s loadAsync function like here https://github.com/oblador/react-native-vector-icons/issues/789#issuecomment-554675931
-
Import font ttf file in local src and link to it with absolute path.
None of the above seems te work and the material font is used in the internals of react-native-paper
/Users/kevin/Enorm/xclsv-500/node_modules/@expo/vector-icons/build/MaterialIcons.js
import createIconSet from './createIconSet';
import font from './vendor/react-native-vector-icons/Fonts/MaterialIcons.ttf';
import glyphMap from './vendor/react-native-vector-icons/glyphmaps/MaterialIcons.json';
export default createIconSet(glyphMap, 'material', font);
//# sourceMappingURL=MaterialIcons.js.map
_Originally posted by @kevinvugts in https://github.com/callstack/react-native-paper/issues/1347#issuecomment-606694962_
I understand that bugs without reproducible code have low priority. Tho i am not able to create one since this is a private project. Hopefully someone has experienced this before. Thanks for any help. Really appreciate it. ❤️
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 32 (6 by maintainers)
I spent a few frustrating hours after upgrading from Expo 39 to Expo 40 on this one. I had initially resolved the issue by installing
expo-fontseparately and adding apostinstallscript to remove the./node_modules/expo/node_modules/expo-fontfolder, as suggested in a forum post linked above.However, I finally solved the issue without the
postinstallworkaround after I noticed this warning:npm install expo-fonthad added v9.0.0 and this was causing Expo to install a second font package, which seemed to cause a conflict. Deleting mynode_modulesfolder and installingexpo-font@~8.4.0resolved the problem and the need for thepostinstallscript was no longer necessary. Presumably, I could have avoided this if I had usedexpo install expo-fontin the first place.–
TL;DR: It seems like there are various things that can cause the “font has not been loaded” error message. Make sure you have the right version of
expo-fontinstalled for your version of Expo if other solutions here aren’t working.I have been having the exact same problem. Tried all solutions from all forums. Nothing works.
this work for me
I tried everything. Absolutely everything. SDF 39.0.0., Android 10, React Hooks, followed official examples, I’ve lost hours with this crap. This is appalling. I’ve deleted node_modules, expo, package-lock.json, npm cache, reinstalled npm packages, expo-font, also @use-expo/font, absolutely everything. Async functions, with and/or without useEffect, no luck.
I got this problem from a version mismatch between expo and expo-font caused by using
yarnto downloadexpo-font. To fix it, I just ranyarn remove expo-fontand then ranexpo install expo-font. Using expo to install rather than yarn directly made it so that expo automatically downloaded a matching version which worked.I have learned the lesson of using
expo installinstead ofyarn addfor my future package downloads.That raises the question, why is the latest version of
expo-fontincompatible with the latest version of expo?How I solved it:
This same issue has been posted around our github and forums a few times, mostly with the solutions above being the fix, or installing the
expo-fontpackage.If you can’t provide a reproducible demo, then I think the best course of action is to look at those other threads and try their fixes in your own project
@kevinvugts try removing expo cache from your home folder. In my system under ~/.cache/expo. It seems it fixed the problem to me
@kevinvugts just remove and regenerate your lock file. In our case it was
package-lock.json. After that this issue is gone.Hi guys, it worked for me,
it was the only way that I could figure it out.
Update: Created an issue, etc, and got it fixed with a method not mentioned above. Details in this issue: https://github.com/expo/expo/issues/11333
Getting the rephrased error “Unrecognized font family: ‘FONTFAMILYNAME’” after upgrading from Expo 38 to Expo 40. Commenting here since it’s one of the few non-closed threads on the topic.
Definitely feeling the frustration. A list of the things I’ve tried to no avail:
I’m at something of a loss as to what to try next, or how to diagnose the problem. I was just trying to upgrade while in the process of handling iOS 14 date pickers, but now I’m mired in what feels like a much bigger mess. I’ll try to make a small reproducible example.
Also, potentially dumb question: While debugging this, should I use expo start -c? Because that’s what I’ve been doing, but I’m not sure it’s necessary (and it’s time consuming).
Hey guys, I encountered this problem while using yarn workspaces and just wanted to share the experience of how I solved this.
Basically the package.json file in each subproject had a different value for their “expo” (“38.0.2”/“39.0.4” ), and “react-native”(“…sdk-38.0.2.tar.gz”/“…sdk-39.0.4.tar.gz”) fields, which was likely a result of a collaborator updating separately.
This resulted in my yarn lockfile resolving expo installed packages to duplicate values, like expo-font@~8.2.1 & expo-font@~8.3.0 both showing up, and this occurs for most other “expo-…” packages too.
In my case, editing package.json in each of the subprojects to have the same values for expo and react-native, deleting the lockfile & node_modules, and reinstalling packages solved the problem.
Hope this helps someone else out there with the same headache. 😃
hi all, i got the strange error … the font is already loaded as i can see the font changes on screen. however i still got the error is not a system font and has not been loaded through Font.loadAsync…
------ code ---- import React,{useEffect,useState} from ‘react’; import * as eva from ‘@eva-design/eva’; import { ApplicationProvider,IconRegistry} from ‘@ui-kitten/components’; import { useFonts } from ‘@use-expo/font’; import { AppLoading } from “expo”; import { EvaIconsPack } from ‘@ui-kitten/eva-icons’; import Themes from ‘./customTheme_2’; import { default as mapping } from ‘./mapping.json’; import { Provider } from ‘react-redux’; import store from ‘./redux/store’; import Index from ‘./src/components/index’;
export default function App () {
const [SelectedTheme, SetSelectedTheme] = useState(Themes.light);
let [fontsLoaded] = useFonts({ ‘Montserrat-Regular’: require(‘./assets/fonts/NunitoSans/NunitoSans-Regular.ttf’), });
return ( !fontsLoaded? <AppLoading /> : <Provider store={store}> <IconRegistry icons={EvaIconsPack} /> <ApplicationProvider {…eva} theme={{ …eva.dark, …SelectedTheme }} customMapping={mapping}> <Index /> </ApplicationProvider> </Provider> ) }
Same issue, upgrading from SDK 36 to 37. All working fine on 36, no longer working on 37. Tried all above suggestions (already tried before reading this) and no luck. Seems expo-font is just not loading fonts.