-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
[Fabric] Add NAN check for text font sizeMultiplier #24966
Conversation
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.
❤️
@@ -137,8 +137,8 @@ static UIFontWeight RCTUIFontWeightFromFloat(CGFloat fontWeight) { | |||
RCTFontProperties defaultFontProperties = RCTDefaultFontProperties(); | |||
fontProperties = RCTResolveFontProperties(fontProperties); | |||
|
|||
CGFloat effectiveFontSize = | |||
fontProperties.sizeMultiplier * fontProperties.size; | |||
CGFloat sizeMultiplier = !isnan(fontProperties.sizeMultiplier) ? fontProperties.sizeMultiplier : 1.0; |
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.
That's not a proper fix of a problem.
We must have an assert(!isnan(fontProperties.sizeMultiplier)
here, but not defaulting to 1.0
.
Instead, we have to figure out why it's happening (the default text attributes are probably wrong) and fix it there.
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.
Done. :)
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.
Thank you, Wu!!1
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.
@shergin is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This pull request was successfully merged by @zhongwuzw in 3616941. When will my fix make it into a release? | Upcoming Releases |
Summary: Set `sizeMultiplier` to `1.0` if default value is `NAN`, otherwise, text cannot show properly. ## Changelog [iOS] [Fixed] - Add NAN check for text font sizeMultiplier Pull Request resolved: facebook#24966 Differential Revision: D15466559 Pulled By: shergin fbshipit-source-id: 6f8b47eb8e521cb120d7f351cba02dbf1c5411fd
Summary
Set
sizeMultiplier
to1.0
if default value isNAN
, otherwise, text cannot show properly.Changelog
[iOS] [Fixed] - Add NAN check for text font sizeMultiplier
Test Plan
Code like
<Text style={{fontFamily: 'GillSans-Bold'}}>Hello</Text>
, can run properly.