Please provide all the information requested. Issues that do not follow this format are likely to stall.
I'm trying to use a custom font on my app but it doesn't work. I have followed numerous steps from other similar questions but nothing works.
I'm not getting any error.
The path to the assets folder: https://i.stack.imgur.com/loEph.png
This is what I tried:
module.exports = {
project: {
ios: {},
android: {},
},
assets: ['./src/assets/fonts']
};
info Linking assets to ios project
info Linking assets to android project
success Assets have been successfully linked to your project
<Text style={[styles.texto_Titulo, {fontFamily: "LatoBlack"}]}>
ENTRADA
</Text>
Recompiling with npx react-native run-android after react-native link
In android/src/main/assets/fonts they get correctly added.
The name I use is the same and is correct, and I also tried changing the names to lower case but that didn't work.
Why is this not working?
Binaries:
Node: 13.9.0 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 6.13.7 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
IDEs:
Android Studio: Version 3.6.0.0 AI-192.7142.36.36.6241897
Languages:
Python: 2.7.17
npmPackages:
@react-native-community/cli: Not Found
react: 16.9.0 => 16.9.0
react-native: ^0.62.0 => 0.62.0
npmGlobalPackages:
react-native: Not Found
I also got the same issue.... I follow the guideline https://medium.com/@mehran.khan/ultimate-guide-to-use-custom-fonts-in-react-native-77fcdf859cf4.
I Created the react-native.config.js file with
module.exports = {
project: {
ios: {},
android: {},
},
assets: ['./assets/fonts'],
};
run the npx react-native link and also tried with yarn react-native link and there is no error.
I saw the fonts in the android/src/main/assets/fonts folder with my fonts.
I use the same and correct font name which i used in the fonts file but still not getting the desired/custom fonts. I also tried to make the font name in lower case also but that did not work also.
Please look over the issue and resolve it. Thanks
same issue in version 0.62
same issue in version 0.62
I got it working by changing the directory of the assets/fonts folder from the android/src/main/assets to android/app/src/main/assets/fonts
i think the problem is somehow in the linking process/react-native-cli.
This is temporary solution for the problem. But we want it to be fixed as soon as possible, Thanks
As @anwersolangi commented, copying the assets to android/app/src/main/ worked wonders! Please fix this bug for future problems because this is just a workaround and sometimes this just doesnt happen, so its inconsistent.
@anwersolangi did you fix for iOS?
@anwersolangi did you fix for iOS?
I use this for android development only.
npx react-native link isn't working for me after adding
module.export = {
project: {
ios: {},
android: {}
},
assets: ['./assets/fonts/']
}
I had to manually copy my assets directory to android/app/src/main to make them work on Android. For iOS, you'll have to search for a guide or something and edit Info.plist or use xcode to generate it.
Use the manual Linking procedure in this guide
https://medium.com/@mehran.khan/ultimate-guide-to-use-custom-fonts-in-react-native-77fcdf859cf4
For both iOS and Android.
Was it fixed?
I'm using react native newest version to test but it seems to not working
I followed 2 links
https://medium.com/@mehran.khan/ultimate-guide-to-use-custom-fonts-in-react-native-77fcdf859cf4
https://medium.com/react-native-training/react-native-custom-fonts-ccc9aacf9e5e
When i ran react-native link. I saw the fonts were linked to android/app/src/main/assets/fonts
But nothing special then. For the ios, it's working smoothly.
Please give me some advices.
Thank in advance!
Was it fixed?
I'm using react native newest version to test but it seems to not working
I followed 2 links
https://medium.com/@mehran.khan/ultimate-guide-to-use-custom-fonts-in-react-native-77fcdf859cf4
https://medium.com/react-native-training/react-native-custom-fonts-ccc9aacf9e5eWhen i ran react-native link. I saw the fonts were linked to android/app/src/main/assets/fonts
But nothing special then. For the ios, it's working smoothly.
Please give me some advices.
Thank in advance!
Same problem, looking for solutions
@ilya-raevskiy
I've tried to remove react-native.config.js and added the code below to package.json
It's working now. But i think you can keep react-native.config.js.
"rnpm": {
"assets": [
"./src/assets/fonts"
]
}
then rm -rf node_module && yarn install && react-native run-android
I have followed the exact same thing mentioned here and it works
https://medium.com/@mehran.khan/ultimate-guide-to-use-custom-fonts-in-react-native-77fcdf859cf4
Using: Mac OS && React Native 0.62
Use the manual Linking procedure in this guide
https://medium.com/@mehran.khan/ultimate-guide-to-use-custom-fonts-in-react-native-77fcdf859cf4
For both iOS and Android.
it didn't work for my andorid
https://medium.com/@mehrankhandev/ultimate-guide-to-use-custom-fonts-in-react-native-77fcdf859cf4 worked on iOS and Android with RN 0.62.2. If it's not working for you:
Double-check
/android/app/src/main/assets/fonts and b) do ios/MyProjectName/Info.plist & ios/MyProjectName.xcodeproj/project.pbxproj contain rows with the font file names? If not:npx react-native link (or react-native link, depending on your setup)?react-native.config.js as in the article? (note the two dots, .config.js)fontWeight? If yes, try removing it (can cause problems on Android, see https://stackoverflow.com/a/58765980 ).style={{ fontFamily: "SFUIDisplay-Bold" }}? Try it on other <Text> elements in your app to weed out problems related to the element itself (e.g. the fontWeight issue).Good luck!
thankyou sir @lauriharpf , my problem is using fontWeight
thankyou sir @lauriharpf , my problem is using fontWeight
me too. I was using fontWeight: 'bold' without including the bold version of the font in the project. after including that too, worked fine
Most helpful comment
I got it working by changing the directory of the assets/fonts folder from the android/src/main/assets to android/app/src/main/assets/fonts
i think the problem is somehow in the linking process/react-native-cli.
This is temporary solution for the problem. But we want it to be fixed as soon as possible, Thanks