首页 > 解决方案 > 在 react-native 0.61.4 中出现错误 Unrecognized font family 'din-next-lt-w23-regular' 仅适用于 iOS

问题描述

我在我的应用程序中使用字体。所以我需要在我的应用程序中添加字体din-next-lt-w23-regular。但我在 iOS 中遇到错误,即Unrecognized font family 'din-next-lt-w23-regular'. 我在ios/Resourcesinfo.plist中添加了.ttf文件。这是我的代码 react-native.config.js

module.exports = {
  project: {
    ios: {},
    android: {},
  },
  assets: ['./assets/fonts/'], 
};

截屏:- 在此处输入图像描述

标签: iosreact-native

解决方案


检查字体的PostScript 名称,它是 IOS 用来识别字体的。您可以在 Font book 中查看字体文件的postscript 名称

这是向 react-native 添加字体的好指南https://medium.com/@mehran.khan/ultimate-guide-to-use-custom-fonts-in-react-native-77fcdf859cf4


推荐阅读