Skip to content

[Fabric] Add NAN check for text font sizeMultiplier - #24966

Closed
zhongwuzw wants to merge 2 commits into
react:masterfrom
zhongwuzw:fix_fabric_sizeMultiplier
Closed

[Fabric] Add NAN check for text font sizeMultiplier#24966
zhongwuzw wants to merge 2 commits into
react:masterfrom
zhongwuzw:fix_fabric_sizeMultiplier

Conversation

@zhongwuzw

Copy link
Copy Markdown
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 sherginMay 20, 2019 09:01
@facebook-github-botfacebook-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

@sherginshergin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❤️


CGFloat effectiveFontSize =
fontProperties.sizeMultiplier * fontProperties.size;
CGFloat sizeMultiplier = !isnan(fontProperties.sizeMultiplier) ? fontProperties.sizeMultiplier : 1.0;

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Done. :)

Copy link
Copy Markdown
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

@facebook-github-botfacebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Collaborator

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

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

@react-native-botreact-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: react#24966
Differential Revision: D15466559
Pulled By: shergin
fbshipit-source-id: 6f8b47eb8e521cb120d7f351cba02dbf1c5411fd
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BugCLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.MergedThis PR has been merged.Platform: iOSiOS applications.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@zhongwuzw@react-native-bot@shergin@facebook-github-bot