-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to access fonts from res/font folder? #15170
Comments
You can certainly load the font yourself and inject into ReactFontManager. Also I don't think having res/font font files and loading from xml is an absolute requirement. Most react-native apps simply don't deal with xml created views, so loading from assets is fine for most. I'd imagine this will not be a highly-requested feature, but it'd a nice addition nonetheless. This method |
If someone wants to add label to the question (I can't) -- choose "Android" and "Feature Request". |
Thanks for opening the issue! As it happens, we're using GitHub to track bugs in React Native. If you'd like to submit this as a feature request, please go ahead and create an entry on Canny. It has a voting system and if the feature gets a good amount of votes, it will have a greater chance of being implemented by the community. Closing this now, thanks for understanding! |
Hello. I am reopening this issue/ feature request again as the link for Canny does not seem to work. I tried to put my fonts in the Android res folder but that does not seem to work with React Native 0.51 . Unfortunately I must put my custom fonts both in the res folder and in the assets/fonts folder so I can use them in React Native and Android ( native) respectively. Is there any solution for this I might have overseen? |
Correct link to Canny https://react-native.canny.io/feature-requests What's the point of putting your custom fonts in res folder, why not just keep them in assets? Android's support for assets folder did not disappear just because now they made res folder the suggested location. If you want, create the Typeface from res yourself, and inject into RN via https://github.com/facebook/react-native/blob/0.50-stable/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactFontManager.java#L83 |
There would be no point and you would be right if I did not have to use the same fonts in the Android Java/XML code too. Now I am obligated to add the fonts two times, one in the assets/fonts folder and one in the res/font folder. Or I have to use your suggestion and add them programmatically. Thank you for the correct Canny link. |
As to provide custom fonts in react native I need to keep my fonts at assets/fonts. But as per the new version of support library of android I have to keep fonts in res/font in order to apply it directly in xml. So I cannot keep my fonts at assets/fonts. Please update this in React native so that the res/font are directly accessible
The text was updated successfully, but these errors were encountered: