用户为 React-native 应用上传了 FontFamily [英] User uploaded FontFamily for React-native App

查看:39
本文介绍了用户为 React-native 应用上传了 FontFamily的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 react-native 项目,我必须在其中实现一个功能,用户可以在其中为应用设置自定义主题,主题包括主题颜色、字体颜色和字体系列.我现在面临的问题是字体系列的要求是用户可以从将在整个应用程序中实现的应用程序上传自定义字体系列.我已经搜索过它,但我找不到任何关于如何获取用户上传的字体系列并将其与我的资产链接,然后在我的应用程序中使用它的任何信息.

I am working on a react-native project, in which I have to implement a functionality in which user can set a custom theme for the app, the theme includes Theme color, font color and font family. The problem I'm facing right now is that the requirement for font family is that user can upload a custom font family from the application that will implemented throughout the application. I have searched about it but i haven't been able to find anything about how I can take a font family that user uploads and link it with my assets and then use it in my application.

推荐答案

在 React Native 中,你需要将字体链接到 android &ios 文件夹.

In React Native, you need to link the fonts to android & ios folder.

链接字体将在 Info.plist 文件 (ios) & 中创建每个字体的条目.在 android/src/main 的 assets 文件夹中.

Linking fonts will create each font's entry in Info.plist file (ios) & in assets folder of android/src/main.

这是强制性.

此外,在项目根文件夹中创建 react-native.config.js 文件并添加以下文本:

Also, create react-native.config.js file in project root folder and add below text:

module.exports = {
    project: {
        ios: {},
        android: {},
    },
    assets: ['./src/assets/fonts']
    };

这篇关于用户为 React-native 应用上传了 FontFamily的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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