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

Android: Add a maxFontSizeMultiplier prop to <Text> and <TextInput> #23069

Conversation

rigdern
Copy link
Contributor

@rigdern rigdern commented Jan 18, 2019

Equivalent of this iOS PR: #20915

Motivation:

Whenever a user changes the system font size to its maximum allowable setting, React Native apps that allow font scaling can become unusable because the text gets too big. Experimenting with a native app like iMessage on iOS, the font size used for non-body text (e.g. header, navigational elements) is capped while the body text (e.g. text in the message bubbles) is allowed to grow.

This PR introduces a new prop on <Text> and <TextInput> called maxFontSizeMultiplier. This enables devs to set the maximum allowed text scale factor on a Text/TextInput. The default is 0 which means no limit.

Test Plan:

I created a test app which utilizes all categories of values of maxFontSizeMultiplier:

  • undefined: inherit from parent
  • 0: no limit
  • 1, 1.2: fixed limits

I tried this with Text, TextInput with value, and TextInput with children. For Text, I also verified that nesting works properly (if a child Text doesn't specify maxFontSizeMultiplier, it inherits it from its parent).

Lastly, we've been using a version of this in Skype for several months.

Changelog:

[Android] [Added] - Added maxFontSizeMultiplier prop to prevent some text from getting unusably large as user increases OS's font scale setting

Adam Comella
Microsoft Corp.

Equivalent of this iOS PR: facebook#20915

Motivation:
----------

Whenever a user changes the system font size to its maximum allowable setting, React Native apps that allow font scaling can become unusable because the text gets too big. Experimenting with a native app like iMessage on iOS, the font size used for non-body text (e.g. header, navigational elements) is capped while the body text (e.g. text in the message bubbles) is allowed to grow.

This PR introduces a new prop on `<Text>` and `<TextInput>` called `maxFontSizeMultiplier`. This enables devs to set the maximum allowed text scale factor on a Text/TextInput. The default is 0 which means no limit.

Test Plan:
----------

I created a test app which utilizes all categories of values of `maxFontSizeMultiplier`:
  - `undefined`: inherit from parent
  - `0`: no limit
  - `1`, `1.2`: fixed limits

I tried this with `Text`, `TextInput` with value, and `TextInput` with children. For `Text`, I also verified that nesting works properly (if a child `Text` doesn't specify `maxFontSizeMultiplier`, it inherits it from its parent).

Lastly, we've been using a version of this in Skype for several months.

Changelog:
----------

[Android] [Added] - Added maxFontSizeMultiplier prop to prevent some text from getting unusably large as user increases OS's font scale setting
@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 Jan 18, 2019
@react-native-bot react-native-bot added 🔶Components Component: TextInput Related to the TextInput component. Platform: Android Android applications. labels Jan 18, 2019
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.

@mdvacca has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Jan 23, 2019
@react-native-bot
Copy link
Collaborator

@rigdern merged commit 4936d28 into facebook:master.

@facebook facebook locked as resolved and limited conversation to collaborators Jan 23, 2019
@react-native-bot react-native-bot added the Merged This PR has been merged. label Jan 23, 2019
@rigdern rigdern deleted the rigdern/maxContentSizeMultiplier-android branch January 23, 2019 21:01
@hramos hramos removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Feb 6, 2019
matt-oakes pushed a commit to matt-oakes/react-native that referenced this pull request Feb 7, 2019
…acebook#23069)

Summary:
Equivalent of this iOS PR: facebook#20915

Motivation:
----------

Whenever a user changes the system font size to its maximum allowable setting, React Native apps that allow font scaling can become unusable because the text gets too big. Experimenting with a native app like iMessage on iOS, the font size used for non-body text (e.g. header, navigational elements) is capped while the body text (e.g. text in the message bubbles) is allowed to grow.

This PR introduces a new prop on `<Text>` and `<TextInput>` called `maxFontSizeMultiplier`. This enables devs to set the maximum allowed text scale factor on a Text/TextInput. The default is 0 which means no limit.
Pull Request resolved: facebook#23069

Differential Revision: D13748513

Pulled By: mdvacca

fbshipit-source-id: 8dd5d6d97bf79387d9a2236fa2e586ccb01afde9
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Component: TextInput Related to the TextInput component. Merged This PR has been merged. p: Microsoft Partner: Microsoft Partner Platform: Android Android applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants