如何在 React-Native 中使用 Google 可变字体

Jos*_*i G 5 fonts react-native google-fonts

我正在尝试在react-native中使用谷歌自定义字体,但遇到问题,我OpenSans从谷歌下载了字体并正确配置了它react-native

字体文件 OpenSans-VariableFont_wdth,wght.ttf

我想用它

{
fontSize: 18,
fontFamily:"OpenSans-Bold"
},
Run Code Online (Sandbox Code Playgroud)

但我遇到了类似的问题Unrecognized font family 'OpenSans-Bold'。但如果我给予喜欢,它就会起作用OpenSans-Regular

我怎样才能使用这个文件OpenSans-VariableFont_wdth,wght.ttf

Mar*_*ria 0

这就是我的方式

<style>@font-face {font-family: "OpenSans-Regular";src: url("OpenSans-VariableFont_wght.ttf");}</style>
Run Code Online (Sandbox Code Playgroud)
对于 iOS,不要忘记将其添加到您的 web 视图中

src={ {html:xxxx, baseUrl: '' }}
originWhitelist={['*']}
Run Code Online (Sandbox Code Playgroud)