React Native无法识别的字体家族无法修复 [英] React Native Unrecognized font family not fixing
问题描述
这些字体在我的资产文件夹中,它们也位于xcode副本捆绑资源中,也位于资源文件夹中.我也已经运行了react-native链接,但是它仍然找不到字体.有什么我想念的吗?请参阅所附图片以供参考:
The fonts are in my asset folder, they are also inside xcode copy bundle resources, and also inside resource folder. I already also ran react-native link, but it still doesn't find the font. Is there something I missed? Please see attached images for reference:
在此处输入图片描述
推荐答案
反应本机部分:
将字体添加到react-native
项目的根文件夹的assets/fonts
中
Add fonts to assets/fonts
of the root folder of react-native
project
react-native-project/
package.json
ios/
android/
assets/
fonts/
GROBOLD...
...
将以下代码段添加到package.json
"rnpm": {
"assets": [
"./assets/fonts/"
]
}
在react-native
项目中运行以下命令以链接资产.
Run the following command in your react-native
project to link your assets.
react-native link react-native-vector-icons
iOS部分:
检查info.plist
中的字体文件是否已经添加.
Check info.plist
for the font files whether they have added already.
删除派生数据,构建并运行Xcode项目.
Delete derived data, build and run your Xcode project.
通过导航到AppDelegate.m
文件再次检查添加到项目中的字体,并在NSURL *jsCodeLocation
下面添加以下代码行;
Double check the fonts added to project by navigating to the AppDelegate.m
file and add these lines of code below NSURL *jsCodeLocation
;
for (NSString* family in [UIFont familyNames])
{
NSLog(@"%@", family);
for (NSString* name in [UIFont fontNamesForFamilyName: family])
{
NSLog(@" %@", name);
}
}
Android部分:
如果字体文件尚不存在,则将其复制到.
Copy the font files to if they are not exist already.
android/
app/
src/
main/
assets/
fonts/
GROBOLD...
这篇关于React Native无法识别的字体家族无法修复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!