react-native-vector-icons字体真棒5 Pro图标不起作用

时间:2019-08-11 08:09:52

标签: react-native react-native-ios react-native-vector-icons

我正在尝试在react-native-vector-icons中使用fontAwesome5Pro。甚至fontAwesome5非专业图标似乎也没有显示。显示较旧的字体真棒4图标。我确实有Pro版本的fontawesome,并且运行了将我的react-native-vector-icons自动更新为pro fontAwesome:./node_modules/.bin/fa5-upgrade的命令,并输入了fontAwesome npm令牌。这部分似乎已经成功。

我在应用程序中遇到此错误:

enter image description here

图标仅显示为问号。

代码:

import AwesomeIcon from 'react-native-vector-icons/FontAwesome5Pro'

<AwesomeIcon
     style={{
         marginLeft: 20
     }}
     name={'utensils'}
/>

我已将图标放入xCode:

enter image description here

我已经在项目中得到了图标,如VS Code所示:

enter image description here

package.json中的rnpm引用了字体:

enter image description here

由于this SO answer,我已将“ react-native-vector-icons”从6.6.0版本更改为6.3.0版本。但是我仍然遇到同样的错误。我还能检查什么才能使这些真棒字体专业图标正常工作?

4 个答案:

答案 0 :(得分:0)

字体不在info.plist

解决方案:将其添加到应用程序其他字体所在的info.plist

<string>FontAwesome5_Pro_Solid.ttf</string>
<string>FontAwesome5_Pro_Brands.ttf</string>
<string>FontAwesome5_Pro_Light.ttf</string>
<string>FontAwesome5_Pro_Regular.ttf</string>

答案 1 :(得分:0)

更新字体后,运行 for ($i = $l+1; $i <= $r; $i++) { if ($str[$l] == $str[$l]) { continue; } $str = swap($str, $l, $i); permute($str, $l + 1, $r, $pspell_link); $str = swap($str, $l, $i); } 将字体复制到相应的平台(ios / android)

答案 2 :(得分:0)

就我而言,我通过以下方式修复它:

  1. 对于 ios:

“FontAwesome5Pro-Solid.ttf”的命名(都添加对Resources的引用和添加到info.plist)

  1. 安卓版 资产/字体中的文件命名应为“FontAwesome5_Pro_Solid.ttf”

命名不同,但文档从不这么说。 顺便说一句,android 必须使用真机,模拟器不会渲染 fontawesome pro 图标。

答案 3 :(得分:-1)

要使用FontAwesome5Pro,您应该购买它的许可证。 您可以通过向下导入文本来使用FontAwesome5的所有免费图标:

import AwesomeIcon from 'react-native-vector-icons/FontAwesome5