自定义字体在本机反应中不起作用 [英] custom font is not working in react native
问题描述
将字体保存在我项目的资产文件夹中后,我通过命令 react-native link
链接了它链接已安装,我交叉检查了 android>src>main>assets>fonts
中的安装,那里也一切正常,我希望使用样式 fontFamily 获得自定义字体:'Coda-Heavy'
但我没有在运行中获得所需的自定义字体
After saving the fonts in my assets folder of my project I linked it by the command react-native link
the links were installed and I cross checked the installation in my android>src>main>assets>fonts
and everything was fine there too and I expected to get the custom font using the styling fontFamily: 'Coda-Heavy'
but I didn't get the required custom font in run
另请参阅此链接,我已将其发布为 react native 中的一个问题:
Also please refer to this link I have posted it as an issue in react native:
https://github.com/facebook/react-native/issues/15266
推荐答案
这步骤你做了吗?
1 在主根目录下创建文件夹 /assets/fonts
1 Create folder /assets/fonts
in main root
2 把它放在你的 package.json
"rnpm": {
"assets": ["./assets/fonts"]
}
3 然后再次运行react-native link
4 您的字体将被复制到 android/app/src/main/assets/fonts
4 Your font will be copied to android/app/src/main/assets/fonts
这篇关于自定义字体在本机反应中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!