问题描述
有没有办法在 Atom 编辑器的 React Native 中添加自定义字体而不使用 Xcode?
Is there a way to add custom font in React Native in Atom editor and not using Xcode?
推荐答案
使用 rnpm
可以通过命令行更轻松地做事.它将字体添加到 android 和 ios.将要添加的字体放置在项目目录中的合适位置.在您的 package.json 中添加以下内容:
There is an easier way of doing things through command line using rnpm
. It adds fonts to both android and ios. Place the font you want to add to a suitable location inside your project directory. In your package.json just add the following:
...rnpm":{资产":[路径/到/您的/字体/目录"]},...然后从命令行执行:rnpm link
您现在可以愉快地在您的应用中使用您的字体了.
you can now happily use your fonts in your app.
注意:你必须安装 rnpm 才能工作.只需执行 npm install -g rnpm
Note: you have to have rnpm installed for this to work.Just do npm install -g rnpm
这里是文档:https://github.com/rnpm/rnpm#advanced-usage
这篇关于如何在不使用 Xcode 的情况下在 React Native 中添加自定义字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!