使用 React Native 在 iOS 模拟器上无法识别的字体系列 [英] Unrecognized font family on iOS simulator with React Native

查看:70
本文介绍了使用 React Native 在 iOS 模拟器上无法识别的字体系列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加了 Linux Biolinum 字体 (

我的风格是:

customFontRegular: {fontFamily: 'LinBiolinum_R',},

我已经尝试将字体文件和字体系列重命名为MyFont",但错误再次出现在 iOS 上.

有什么想法吗?

解决方案

在 Android 上,它采用文件名,您就完成了.然而,在 iOS 上它有点复杂.

您应该采取以下几个步骤:

  • 仔细检查 XCode 中的 Target 中是否包含字体文件
  • 确保它们包含在复制捆绑资源"步骤中(添加文件,而不是文件夹)
  • 将它们包含在应用的 Info.plist 中
  • 通过 FontBook 或 AppDelegate 中的一些日志语句找到字体的名称

这里有更详细的解释:http://codewithchris.com/common-错误添加自定义字体到您的 ios-app/

祝你好运!

I've added Linux Biolinum fonts (http://www.dafont.com/linux-biolinum.font, LinBiolinum_R.ttf, LinBiolinum_RB.ttf) to my React Native project. Android version is OK. But on iOS I always see error "Unrecognized font family LinBiolinum_R".

My style is:

customFontRegular: {
    fontFamily: 'LinBiolinum_R',
},

I've tryied to rename font file and font family to "MyFont", but the error appears again on iOS.

Any ideas?

解决方案

On Android it takes the name of the file and you are done. On iOS however it is a bit more complex.

There are a few steps you should take:

  • Double check the font files are included in the Target in XCode
  • Make sure they are included in the step "Copy Bundle Resources" (add files, not folders)
  • Include them in the Info.plist of the app
  • Find the name of the Font through FontBook or with some log statements in your AppDelegate

Explained in more detail here: http://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/

Good luck!

这篇关于使用 React Native 在 iOS 模拟器上无法识别的字体系列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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