gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 08:03:29 24 4
gpt4 key购买 nike

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

字体文件OpenSans-VariableFont_wdth,wght.ttf

我正在尝试像这样使用它

{
fontSize: 18,
fontFamily:"OpenSans-Bold"
},

但我遇到了类似Unrecognized font family 'OpenSans-Bold' 的问题。但是,如果我像 OpenSans-Regular 一样工作,它就会起作用。

我如何使用这个文件 OpenSans-VariableFont_wdth,wght.ttf

最佳答案

我的是这样的

<style>@font-face {font-family: "OpenSans-Regular";src: url("OpenSans-VariableFont_wght.ttf");}</style>
对于 iOS,不要忘记将此添加到您的 webview

src={ {html:xxxx, baseUrl: '' }}
originWhitelist={['*']}

关于react-native - 如何在 React-Native 中使用 Google 可变字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72629402/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com