Inconsistent scaling with adjustsFontSizeToFit and numberOfLines=1
See original GitHub issueIs 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
- Create a Text element with
adjustsFontSizeToFit
andnumberOfLines={1}
- 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
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:5
Top Results From Across the Web
React Native font scale
I have problem with scaling font inside of View or better to say inside ... <Text adjustsFontSizeToFit minimumFontScale={.4}>Automatically ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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>
.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.