如何在 React Native android 中添加自定义字体

如何在 React Native android 中添加自定义字体

问题描述:

我想将 fontFamily 设置为比我的工具栏标题更薄的机器人.

I want to set fontFamily to roboto thin of my toolbar title.

我在我的 android 项目的 assets/fonts 文件夹中添加了 Roboto Thin ttf,但是它似乎在运行应用程序时产生了问题.我在运行时遇到这个问题

I have added roboto thin ttf in assets/fonts folder of my android project, however it seems that it is creating issues while running app. I am getting this issue while running

react-native 启动

react-native start

ERROR  EPERM: operation not permitted, lstat 'E:Myntraandroidappuildgener
atedsource
debugandroidsupportv7appcompat'
{"errno":-4048,"code":"EPERM","syscall":"lstat","path":"E:\Myntra\android\app
\build\generated\source\r\debug\android\support\v7\appcompat"}
Error: EPERM: operation not permitted, lstat 'E:Myntraandroidappuildgenera
tedsource
debugandroidsupportv7appcompat'
    at Error (native)

当我删除字体时,它工作正常.我无法解决这个问题.什么原因?

When I am removing the font then it is working fine. I am unable to fix this issue. What's the reason?

  1. 将您的字体文件添加到

  1. Add your fonts file in

  • 项目文件夹/android/app/src/main/assets/fonts/font_name.ttf
  • fontFamily: 'font_name'

在此处查看更多示例自定义字体示例