简体   繁体   中英

User uploaded FontFamily for React-native App

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.

Below are native implementations for ios and android. It may work or not work. For to use in react native you've to create lib having this native code and js code for invoking native functions

Refer to this below link for iOS

Refer to this below link for android

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

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

This is mandatory .

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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