I'm using loadAsync to load some fonts. It worked fine while testing the app on my device, but when I tried on another device (Galaxy s10e), the fonts seem to be loaded (checking with Font.isLoaded) but not displaying when using fontFamily.
This is my App.js
import * as Font from 'expo-font';
import {AppLoading} from 'expo';
import React, {useState} from 'react';
const fetchFonts = async() => {
return await Font.loadAsync ({
secular: require ('./assets/fonts/SecularOne-Regular.ttf'),
varela: require ('./assets/fonts/VarelaRound-Regular.ttf'),
lemon: require ('./assets/fonts/LemonMilk.otf'),
collegiate: require ('./assets/fonts/CollegiateBlackFLF.ttf'),
assistant: require ('./assets/fonts/Assistant-ExtraBold.ttf'),
zvulun: require ('./assets/fonts/zvulun-black-fm.otf'),
roboto: require ('./assets/fonts/Roboto-Medium.ttf'),
osh: require ('./assets/fonts/OpenSansHebrew-ExtraBold.ttf'),
oshregular: require ('./assets/fonts/OpenSansHebrew-Regular.ttf'),
oshlight: require('./assets/fonts/OpenSansHebrew-Light.ttf'),
myriad: require('./assets/fonts/myriad-hebrew.ttf')
});
};
export default function App () {
const [dataLoaded, setDataLoaded] = useState (false);
if (!dataLoaded) {
return (
<AppLoading
startAsync={() => fetchFonts().then(() => console.log('done')).catch((err) => console.log(err))}
onFinish={() => setDataLoaded (true)}
onError={err => console.log (err)}
/>
);
}
return *the actual app*;
}
To be clear, the fonts do load and show correctly on another device (Galaxy s10+).
Expo SDK 37
Android 11
expo-font 8.1.0
question from:
https://stackoverflow.com/questions/65860772/expo-fonts-loadasync-not-working-in-specific-device-react-native-android 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…