如何在不使用 Xcode 的情况下在 React Native 中添加自定义字体? [英] How do I add custom font in React Native not using Xcode?

查看:37
本文介绍了如何在不使用 Xcode 的情况下在 React Native 中添加自定义字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 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 中添加自定义字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆