-
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
Supporting custom fonts the Android Way #19736
Comments
We might implement a way to request font download using native module, which would greatly enhance developer and user experience. https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts |
Is there currently any way to reference fonts in android by their appropriate weight, beyond normal/bold? (i.e. not by putting the weight in FontFamily.) |
@dulmandakh now that we have https://github.com/react-native-community/discussions-and-proposals in place, perhaps that's a better place for this type of discussion? |
It appears to me that any font-weight on android above '400' just gives bold text. Looking for a way to support in-between font weights of 500 or 600. |
after RN 0.57.4 android, The font has become thicker !! why?? |
Thanks for sending a PR for this @dulmandakh, this feature is currently landing in #23865 so I'm gonna close this issue. |
it's landed in another PR and commit :D |
For Discussion
Android SDK 26 introduced easy way to support custom fonts, where users define font family using XML and use it with ResourcesCompat.getFont(context, R.font.myfont). Read https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml
Current React Native support for custom fonts on Android implemented in ReactFontManager and CustomStyleSpan, and it's hard to use font weights other than bold and regular (normal), like medium, light etc. To use custom font weights on Android, I have to specify font file name without extension in fontFamily of style, which breaks iOS apps. Therefore, I check the platform in JS to support both Android and iOS, and set fontFamily and fontWeight accordingly.
Adding support for Android Way seemed trivial with fallback to old way.
But, font styling of Text in Android implemented in ReactBaseTextShadowNode, which have no access to context. So, I think support custom fonts the Android Way will require refactoring of Text and decide if RN will support the OLD WAY.
Please consider this for FabricUIManager
CC: @hramos @mdvacca
The text was updated successfully, but these errors were encountered: