Skip to content
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

Closed

Conversation

zhongwuzw
Copy link
Contributor

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

Test Plan

Code like <Text style={{fontFamily: 'GillSans-Bold'}}>Hello</Text>, can run properly.

@zhongwuzw zhongwuzw requested a review from shergin May 20, 2019 09:01
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 20, 2019
@react-native-bot react-native-bot added Bug Platform: iOS iOS applications. labels May 20, 2019
Copy link
Contributor

@shergin shergin left a 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;
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, Wu!!1

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @zhongwuzw in 3616941.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label May 23, 2019
M-i-k-e-l pushed a commit to M-i-k-e-l/react-native that referenced this pull request Mar 10, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Platform: iOS iOS applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants