react-native 使用自定义字体

https://blog.logrocket.com/adding-custom-fonts-react-native/

  1. 项目根目录新建react-native.config.js
module.exports = {
project: {
ios: {},
android: {},
},
assets: ["./assets/fonts"],
};
  1. 项目根目录新建/assets/fonts/Dosis.ttf
    执行:
npx react-native-asset
info Linking ttf assets to iOS project
WARN ERRGROUP Group 'Resources' does not exist in your Xcode project. We have created it automatically for you.
info Linking ttf assets to Android project
textPrice: {
fontSize: 20,
color: '#333',
fontFamily: 'Dosis',
}
作者

陈桥驿站

发布于

2024-07-25

更新于

2024-09-15

许可协议

评论