-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Android does not allow for use of all font weights even when explicitly provided #27310
Comments
I'm having the exact same issue, is there any workaround until this is resolved? |
Also having same issue
Check this line |
Check this #26193 (comment) for solution |
I wrote a npm package react-native-font-weight (alpha) to handle fontWeights on Android. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information. |
React Native version: 61.4
Problem
I'm declaring a custom font with all weights (300, 400, 500, 600, 700, 800, 900). I then have a Text node with fontWeight: '700' but because of the logic in ReactBaseTextShadowNode.setFontWeight() it gets reset to Typeface.BOLD. So if I use '800' or '900' it works correctly but specifically '700' gets reset to bold.
Further adding to my confusion is the fact that this logic differs from other setFontWeight() methods where anything over 500 is reset to bold. Then all three methods claim to be duplicates of the code of one another.
My question:
What should the proper logic be. Why are fontWeights being reset to bold and why '700' specifically in the case of ReactBaseTextShadowNode? In my search for a solution I also came across #25341 which seems related.
Here are all the various
setFontWeight
methods found throughout the android codebase.Steps To Reproduce
addCustomFont()
Describe what you expected to happen:
I expect to be able to use all font weights that are available on both iOS and Android. This is possible on iOS but not Android.
Link to a repository:
https://github.com/aforty/react-native-android-font-weight-bug
Notice how the fonts are defined in
android/app/src/main/res/font
and then registered inMainApplication.onCreate()
.The text was updated successfully, but these errors were encountered: