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

<Text> Expose Android's includeFontPadding property to JavaScript. #9323

Closed

Conversation

benvium
Copy link
Contributor

@benvium benvium commented Aug 9, 2016

By default Android will put extra space above text to allow for upper-case accents or other ascenders. With some fonts, this can make text look slightly misaligned when centered vertically.

We have found that the effect is very noticeable with certain custom fonts on Android. On iOS the font aligns vertically as expected.

Android exposes a property includeFontPadding that will remove this extra padding if set to false. This PR exposes that to JS, and adds it to the documentation and UIExplorer.

Test Plan:

  • Run UIExplorer
  • Scroll down to find the option
  • Click and scroll to bottom to see a sample with the default text vertical alignment (includeTextPadding: true) and the result when using includeTextPadding: false.

screen shot 2016-08-09 at 17 38 05

Add example to UIExplorer (android only)

By default Android will put extra space above text to allow for upper-case accents or other ascenders. With some fonts, this can make text look slightly misaligned when centered vertically. Android OS supplies a useful property includeTextPadding that can alleviate this effect for some fonts.
We have found that the effect is very noticeable with certain custom fonts on Android. On iOS the font aligns vertically as expected.

Test Plan:

- Run UIExplorer
- Scroll down to find the <Text> option
- Click and scroll to bottom to see a sample with the default text vertical alignment (includeTextPadding: true) and the result when using includeTextPadding: false.
@ghost
Copy link

ghost commented Aug 9, 2016

By analyzing the blame information on this pull request, we identified @skv-headless and @spicyj to be potential reviewers.

@ghost
Copy link

ghost commented Aug 9, 2016

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks!

@ghost ghost 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 Aug 9, 2016
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@@ -411,6 +411,23 @@ class TextExample extends React.Component {
This very long text should be truncated with dots in the beginning.
</Text>
</UIExplorerBlock>
<UIExplorerBlock title="Include Font Padding">
<View style={{flexDirection: "row", justifyContent: 'space-around', marginBottom: 10}}>

Choose a reason for hiding this comment

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

quotes: Strings must use singlequote.

@ghost
Copy link

ghost commented Aug 9, 2016

@benvium updated the pull request.

@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 Aug 9, 2016
@rigdern
Copy link
Contributor

rigdern commented Aug 30, 2016

@spicyj, have you had a chance to review this yet? This feature would be useful in my team's app.

Adam Comella
Microsoft Corp.

@sophiebits
Copy link
Contributor

@mkonicek Can you triage?

@ghost ghost 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 Aug 30, 2016
@ghost
Copy link

ghost commented Sep 9, 2016

It's been a while since the last commit was reviewed and the labels show this pull request needs review. Based on the blame information for the files in this pull request we identified @rigdern as a potential reviewer. Could you take a look please or cc someone with more context?

@ghost ghost 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 Sep 9, 2016
@rigdern
Copy link
Contributor

rigdern commented Sep 9, 2016

cc @mkonicek

@ghost ghost 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 Sep 9, 2016
@rigdern
Copy link
Contributor

rigdern commented Oct 10, 2016

ping @mkonicek, this feature would be useful in my team's app. Can somebody review it?

@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 Oct 10, 2016
@hramos
Copy link
Contributor

hramos commented Nov 10, 2016

Triaging...

@lacker lacker self-assigned this Nov 30, 2016
@lacker
Copy link
Contributor

lacker commented Nov 30, 2016

This looks good to me. I wish there were a better way to test this sort of thing but since it's just passing through a parameter this might be overkill.

@lacker
Copy link
Contributor

lacker commented Nov 30, 2016

@benvium Can you resolve the merge conflict and then I'll ship this?

@benvium
Copy link
Contributor Author

benvium commented Nov 30, 2016

@lacker Yes, I can. Will do tomorrow morning UK time. Thank you.

# Conflicts:
#	ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java
@benvium
Copy link
Contributor Author

benvium commented Dec 1, 2016

@lacker I have updated the PR as requested. I re-tested using UIExplorer on API 22 and confirmed that it still works.

@lacker
Copy link
Contributor

lacker commented Dec 1, 2016

The Travis failure seems spurious, let me try rerunning it.

@benvium
Copy link
Contributor Author

benvium commented Dec 2, 2016

@lacker Looks like it succeeded.

@facebook-github-bot facebook-github-bot added GH Review: accepted Import Started This pull request has been imported. This does not imply the PR has been approved. and removed GH Review: review-needed labels Dec 2, 2016
@facebook-github-bot
Copy link
Contributor

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

robclouth pushed a commit to robclouth/react-native that referenced this pull request Dec 7, 2016
Summary:
By default Android will put extra space above text to allow for upper-case accents or other ascenders. With some fonts, this can make text look slightly misaligned when centered vertically.

We have found that the effect is very noticeable with certain custom fonts on Android. On iOS the font aligns vertically as expected.

Android exposes a property `includeFontPadding` that will remove this extra padding if set to false. This PR exposes that to JS, and adds it to the documentation and UIExplorer.
Closes facebook#9323

Differential Revision: D4266713

Pulled By: lacker

fbshipit-source-id: f9711254bc26c09b4586a865f0e95ef4bf77cf3f
mkonicek pushed a commit that referenced this pull request Dec 12, 2016
Summary:
By default Android will put extra space above text to allow for upper-case accents or other ascenders. With some fonts, this can make text look slightly misaligned when centered vertically.

We have found that the effect is very noticeable with certain custom fonts on Android. On iOS the font aligns vertically as expected.

Android exposes a property `includeFontPadding` that will remove this extra padding if set to false. This PR exposes that to JS, and adds it to the documentation and UIExplorer.
Closes #9323

Differential Revision: D4266713

Pulled By: lacker

fbshipit-source-id: f9711254bc26c09b4586a865f0e95ef4bf77cf3f
DanielMSchmidt pushed a commit to DanielMSchmidt/react-native that referenced this pull request Jan 4, 2017
Summary:
By default Android will put extra space above text to allow for upper-case accents or other ascenders. With some fonts, this can make text look slightly misaligned when centered vertically.

We have found that the effect is very noticeable with certain custom fonts on Android. On iOS the font aligns vertically as expected.

Android exposes a property `includeFontPadding` that will remove this extra padding if set to false. This PR exposes that to JS, and adds it to the documentation and UIExplorer.
Closes facebook#9323

Differential Revision: D4266713

Pulled By: lacker

fbshipit-source-id: f9711254bc26c09b4586a865f0e95ef4bf77cf3f
rozele pushed a commit to microsoft/react-native-windows that referenced this pull request Feb 7, 2017
Summary:
By default Android will put extra space above text to allow for upper-case accents or other ascenders. With some fonts, this can make text look slightly misaligned when centered vertically.

We have found that the effect is very noticeable with certain custom fonts on Android. On iOS the font aligns vertically as expected.

Android exposes a property `includeFontPadding` that will remove this extra padding if set to false. This PR exposes that to JS, and adds it to the documentation and UIExplorer.
Closes facebook/react-native#9323

Differential Revision: D4266713

Pulled By: lacker

fbshipit-source-id: f9711254bc26c09b4586a865f0e95ef4bf77cf3f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Import Started This pull request has been imported. This does not imply the PR has been approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants