小编gui*_*oof的帖子

在我的react-native应用程序中添加自定义字体时,iOS上的Thin&Light fontWeight没有区别

我刚刚将自定义字体添加到我的react-native应用程序(https://fonts.google.com/specimen/Josefin+Sans).

JosefinSans-Bold.ttf
JosefinSans-BoldItalic.ttf
JosefinSans-Italic.ttf
JosefinSans-Light.ttf
JosefinSans-LightItalic.ttf
JosefinSans-Regular.ttf
JosefinSans-SemiBold.ttf
JosefinSans-SemiBoldItalic.ttf
JosefinSans-Thin.ttf
JosefinSans-ThinItalic.ttf
Run Code Online (Sandbox Code Playgroud)

react-native link在添加后通过运行链接了字体文件

"rnpm": {
  "assets": [
    "path/to/my/font/files"
  ]
},
Run Code Online (Sandbox Code Playgroud)

对我的 package.json

然后,我在我的应用程序中使用字体,如下所示:

customFont: {
    fontFamily: 'Josefin Sans',
},
thin: {
    fontWeight: '100'
},
light: {
    fontWeight: '300'
},
semiBold: {
    fontWeight: '600'
},
bold: {
    fontWeight: '700'
},
italic: {
    fontStyle: 'italic'
},
Run Code Online (Sandbox Code Playgroud)

iOS模拟器截图不同的fontWeight和fontStyle

问题是thin(fontWeight: '100')&之间没有区别light(fontWeight: '300').

到目前为止我尝试过的:

  • 尝试使用谷歌字体中的另一种字体(同样的问题).
  • 试图在实际设备(而不是模拟器)上运行应用程序,但徒劳无功.
  • 尝试使用iOS默认字体与那些fontWeights:thin并且light是真正可识别的
  • 在xcode中显示字体实际名称(JosefinSans-LightJosefinSans-Thin):

_ …

fonts custom-font ios react-native

6
推荐指数
1
解决办法
919
查看次数

标签 统计

custom-font ×1

fonts ×1

ios ×1

react-native ×1