简体   繁体   English

React native Expo 自定义字体 android issue

[英]React native Expo Custom font android issue

I tried using a custom font Avenir-book.tff and AvernirNext.otf for my expo project.我尝试为我的 expo 项目使用自定义字体 Avenir-book.tff 和 AvernirNext.otf。 For some reason my custom font works in my iOS device but doesn't work for my android device.出于某种原因,我的自定义字体适用于我的 iOS 设备,但不适用于我的 android 设备。 Here my code: app.js:这是我的代码:app.js:

UNSAFE_componentWillMount() {
Font.loadAsync({
  "Avenir-Book": require("./assets/fonts/Avenir-Book.ttf"),
  "Avenir-Next": require("./assets/fonts/AvenirNextLTPro-Bold.otf"),
}).then(() => this.setState({ fontsLoaded: true }));
}

my text:我的文字:

<Text style={styles.text}>ORA</Text>

Style sheet:样式表:

text: {
color: colors.white,
fontSize: 30,
fontFamily: "Avenir-Book",
fontWeight: "bold",
marginTop: 8,
},

I tried using both the fonts. Both works perfectly fine on iOS but doesn't work at all on android. Does anyone know why?我尝试同时使用 fonts。两者在 iOS 上都工作得很好,但在 android 上根本不起作用。有人知道为什么吗?

I think this answer is relevant: https://stackoverflow.com/a/62460424/659988我认为这个答案是相关的: https://stackoverflow.com/a/62460424/659988

Be sure to refer to this minimal and complete working example in the documentation too: https://docs.expo.io/guides/using-custom-fonts/#a-minimal-but-complete-working-example请务必参考文档中的这个最小和完整的工作示例: https://docs.expo.io/guides/using-custom-fonts/#a-minimal-but-complete-working-example

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM