-
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
custom fontWeight numeric values for Text on Android #25341
Conversation
|| (fontWeightNumeric != -1 && fontWeightNumeric < 500)) { | ||
fontWeight = Typeface.NORMAL; | ||
} | ||
int fontWeight = fontWeightNumeric != -1 ? fontWeightNumeric : Typeface.NORMAL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you change -1 for UNSET constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @dulmandakh, thanks for working on this. The code looks good to me, can you just make that small change of the constant? and I will import it
CC @fkgozali as you were involved in changes in the way we manage fonts in android
@mdvacca thanks for your review and comment. I made requested changes, please feel free to review, maybe import the changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mdvacca is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Thanks @dulmandakh, I'm landing it. |
This pull request was successfully merged by @dulmandakh in 3915c0f. When will my fix make it into a release? | Upcoming Releases |
Summary: I found that on Android we only support 2 fontWeight options, either **normal** or **bold**, even developer can set any numeric value. But iOS supports all possible numeric values. This PR tries to add support for all possible numeric values on Android, even if it's supported only on Android P(28) and above. This change might break texts where fontWeight use improperly, because this PR removes conversion of values above 500 to BOLD and below 500 to normal. FYI, also moved **mCustomTypefaceCache** usage up because it was working after unnecessary mFontCache usage. ## Changelog [Android] [Changed] - add custom font weight support to Text component on Android, only on P(API 28) and above versions. Pull Request resolved: #25341 Test Plan: RNTester app's Text examples will show Rubik Regular, Rubik Light, Rubik Bold, Rubik Medium and Rubik Medium Italic texts in corresponding font family, style and weights. Differential Revision: D15956350 Pulled By: mdvacca fbshipit-source-id: 61079d953c65fb34ab4497d44c22317912a5a616
It seems like this change broke previous behavior that was relied upon (my team included): #25696 |
So sorry that the change broke your code, but intention is described in the summary. |
The description does not describe why it was decided that the previous behavior should be broken. New behaviors for P+ might have been appropriate but could have been applied in a backwards-compatible way. |
It's my bad that I didn't expected that developers would depend on this behavior. Please feel free to create a PR and add backwards-compatibility, I would be happy to review and test it. |
I found this PR as I was investigating an issue. My issue: Further adding to my confusion is the fact that this logic differs from other My question:
|
So sad that the old behavior is broken now, because the impact is quite big on our app... |
the previously used fort weight of 500 would effectively be converted to `fontWeight: bold` because of facebook/react-native#25341 this fixes the title appearance to look as customary
the previously used fort weight of 500 would effectively be converted to `fontWeight: bold` because of facebook/react-native#25341 this fixes the title appearance to look as customary Update HeaderTitle.tsx
the previously used fort weight of 500 would effectively be converted to `fontWeight: bold` because of facebook/react-native#25341 this fixes the title appearance to look as customary Update HeaderTitle.tsx
Summary: I found that on Android we only support 2 fontWeight options, either **normal** or **bold**, even developer can set any numeric value. But iOS supports all possible numeric values. This PR tries to add support for all possible numeric values on Android, even if it's supported only on Android P(28) and above. This change might break texts where fontWeight use improperly, because this PR removes conversion of values above 500 to BOLD and below 500 to normal. FYI, also moved **mCustomTypefaceCache** usage up because it was working after unnecessary mFontCache usage. ## Changelog [Android] [Changed] - add custom font weight support to Text component on Android, only on P(API 28) and above versions. Pull Request resolved: facebook#25341 Test Plan: RNTester app's Text examples will show Rubik Regular, Rubik Light, Rubik Bold, Rubik Medium and Rubik Medium Italic texts in corresponding font family, style and weights. Differential Revision: D15956350 Pulled By: mdvacca fbshipit-source-id: 61079d953c65fb34ab4497d44c22317912a5a616
the previously used fort weight of 500 would effectively be converted to `fontWeight: bold` because of facebook/react-native#25341 this fixes the title appearance to look as customary
the previously used fort weight of 500 would effectively be converted to `fontWeight: bold` because of facebook/react-native#25341 this fixes the title appearance to look as customary
the previously used fort weight of 500 would effectively be converted to `fontWeight: bold` because of facebook/react-native#25341 this fixes the title appearance to look as customary
the previously used fort weight of 500 would effectively be converted to `fontWeight: bold` because of facebook/react-native#25341 this fixes the title appearance to look as customary
the previously used fort weight of 500 would effectively be converted to `fontWeight: bold` because of facebook/react-native#25341 this fixes the title appearance to look as customary
the previously used fort weight of 500 would effectively be converted to `fontWeight: bold` because of facebook/react-native#25341 this fixes the title appearance to look as customary
Summary
I found that on Android we only support 2 fontWeight options, either normal or bold, even developer can set any numeric value. But iOS supports all possible numeric values. This PR tries to add support for all possible numeric values on Android, even if it's supported only on Android P(28) and above.
This change might break texts where fontWeight use improperly, because this PR removes conversion of values above 500 to BOLD and below 500 to normal.
FYI, also moved mCustomTypefaceCache usage up because it was working after unnecessary mFontCache usage.
Changelog
[Android] [Changed] - add custom font weight support to Text component on Android, only on P(API 28) and above versions.
Test Plan
RNTester app's Text examples will show Rubik Regular, Rubik Light, Rubik Bold, Rubik Medium and Rubik Medium Italic texts in corresponding font family, style and weights.