有没有办法在 Atom 编辑器的 React Native 中添加自定义字体而不使用 Xcode?
如何在不使用 Xcode 的 React Native 中添加自定义字体?
有一种更简单的方法可以通过命令行使用rnpm. 它将字体添加到 android 和 ios。将要添加的字体放在项目目录中的合适位置。在您的 package.json 中添加以下内容:
...
"rnpm": {
"assets": ["path/to/your/font/directory"]
},
...
然后从命令行执行:rnpm link
您现在可以愉快地在您的应用程序中使用您的字体。
注意:您必须安装 rnpm 才能使用。做就是了npm install -g rnpm
The way without edit package.json is:
Install in your proyect react-native-vector-icons (
npm install --save react-native-vector-icons).Move the fonts into
node_modules/react-native-vector-icons/Fonts.run
react-native link.run
react-native run-ios
The problem is that the name of the fonts is different than the file name. The way to show all names of the installed fonts is modify AppDelegate.m and put the loop:
for (NSString *familyName in [UIFont familyNames]) {
for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
NSLog(@"%@", fontName);
}
}
For icons fonts the name is the same.
Not Possible to add Custom Font iOS .
You are using Xcode then add Font in native app
- Copy your font file into resources
- Add a key to your Info.plist file called UIAppFonts. ("Fonts provided by application)Make this key an array
- For each font you have, enter the full name of your font file (including the extension) as items to the UIAppFonts array