我刚刚将自定义字体添加到我的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').
到目前为止我尝试过的:
thin并且light是真正可识别的JosefinSans-Light和JosefinSans-Thin):_ …