FontFamily 在 React-Native 的 Android 设备中不起作用 [英] FontFamily not working in Android Device in React-Native

查看:74
本文介绍了FontFamily 在 React-Native 的 Android 设备中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 React-Native 项目的资产文件夹中添加了许多字体系列和样式.它在模拟器、模拟器和 iOS 设备中运行良好.但有些字体无法使用,也无法在 Android 设备中显示.

I have added many font-family and style into my asset folder in React-Native project. It's working fine in simulator, emulator, and iOS device. But some font won't work and not display in Android device.

我尝试使用 react-native 链接 并检查 Android 应用目录中的 asset 文件夹,没有遗漏.

I have try with react-native link and check the asset folder in Android app directory, nothing missing.

请任何人帮忙.

推荐答案

我可能有一个解决方案.我遇到了同样的问题,字体在我的模拟器中可见,字体文件位于android/src/main/assets/fonts"下,但在我的物理 android 设备(Huawei Honor 8X)上不可见.

I might have a solution for this. I had the same problem, the fonts were visible in my emulator, the font files are located under 'android/src/main/assets/fonts' and yet it wasn't visible on my physical android device (Huawei Honor 8X).

我发现问题出在我的物理设备的字体设置上.要解决此问题,请在您的手机上转到

I found out that the problem was with my physical device's Font settings. To fix this, on your phone, go to

设置 -> 显示 -> 文本样式 -> 默认

设置屏幕:转到显示

显示设置:查找文本样式,确保将其设置为默认值,如图所示

在此处选择默认值:现在您的自定义应用字体应该可以使用了

请注意,这些设置可能因您的设备而异.我已经提到了我手机的步骤.

Please Note that these settings might differ as per your device. I've mentioned the steps for my phone.

始终使用默认文本样式在您的应用中呈现自定义字体.现在,像 OnePlus 等手机都有自己的自定义字体,我认为这会干扰应用程序中定义的自定义字体.

Always use the default Text Style to render custom fonts in your app. Nowadays, phones like the OnePlus etc. have their own custom fonts and I think this is interfering with custom fonts defined in Applications.

希望这会有所帮助.

这篇关于FontFamily 在 React-Native 的 Android 设备中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆