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

Inconsistent scaling with adjustsFontSizeToFit and numberOfLines=1 #16124

Closed
zachasme opened this issue Sep 28, 2017 · 5 comments
Closed

Inconsistent scaling with adjustsFontSizeToFit and numberOfLines=1 #16124

zachasme opened this issue Sep 28, 2017 · 5 comments
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@zachasme
Copy link

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment:
OS: Linux 4.12
Node: 8.5.0
Yarn: 1.0.1
npm: 5.3.0
Watchman: 4.7.0
Xcode: N/A
Android Studio: Not Found

Packages: (wanted => installed)
react: 16.0.0-alpha.12 => 16.0.0-alpha.12
react-native: 0.48.4 => 0.48.4

Target Platform: iOS (9.3.5)

Steps to Reproduce

  1. Create a Text element with adjustsFontSizeToFit and numberOfLines={1}
  2. Put it in a View and set style={{flex: 1}} on both elements.

Expected Behavior

The paragraph inside the text element is adjusted to fit on a single line, with every word visible.

Actual Behavior

The paragraph is scaled to fit, but inconsistently. Sometimes the last word is cut off. Adding/removing a word sometimes fixes this. See screenshot.

Reproducible Demo

https://snack.expo.io/BkXvD4qjb

@zachasme
Copy link
Author

For anyone else encountering this, as temporary workaround we're adding a regular space followed by a non-breaking space: <Text {...props}>Long Paragraph {"\u00a0"}</Text>.

@CharlieOrlando
Copy link

Finally found someone else with this issue! I have been searching like crazy to find an answer. Has anyone else found a solution besides the hacky workaround??

@iPrytz
Copy link

iPrytz commented Nov 6, 2017

I'm also looking for a better solution for this, i've made a calculator where the text scales if the input is a big number. When it starts to scale, the last char is sometimes cut of :(

@chriscohoat
Copy link

I've been struggling for days on this and I believe the trick is to use a mono-spaced font family as well, like Helvetica Neue. Used in combination with @zachasme's fix everything seems to render properly.

@stale
Copy link

stale bot commented Feb 18, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Feb 18, 2018
@stale stale bot closed this as completed Feb 25, 2018
@facebook facebook locked and limited conversation to collaborators May 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

5 participants
@chriscohoat @zachasme @iPrytz @CharlieOrlando and others