-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Line height is distributed unevenly when lineHeight <= fontSize #29507
Comments
A workaround for readers who stumble on this issue: if you'd like to use smaller line heights without glyph clipping, you'll need to add top padding to the |
Does adding this prop help |
@ravirajn22: Nope, that doesn't change the output, neither on Android nor on iOS. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
Nope, the issue has not been fixed; it still requires attention. I don't seem to have permission to add it to the backlog. |
I can confirm that this is still an issue Thanks for the tip with the workaround @andymatuschak |
Yep, still an issue |
Still an issue |
Agreed, still an issue, bot. |
On Windows, XAML has LineStackingStrategy and TextLineBounds for fine-tuning the text positioning. On web, there's a proposal for "leading-trim". Do iOS or Android have anything similar that could be used or exposed? |
Still an issue |
Same issue here. Basically, any characters that were not part of the font package were causing this issue for me. |
Definitely still an issue and the workaround is not great if you ever have Text within Text, they no longer align when they both have some kind of top offset |
Would be great to bring some attention to this issue. The workaround mentioned in #7687 is hacky and will not work properly with special capital characters (e.g. Å, Á, È) unless you manually tweak paddings to "just about right". |
try just verticalAlign:"bottom" |
Still an issue |
Still an issue |
1 similar comment
Still an issue |
Hey @fabOnReact, it seems like you have the best understanding of this bug. Certain fonts have different ascents/descents and iOS doesn't adjust the baseline based on this difference. This presents unnoticeably on many fonts, but for some other fonts the difference can be drastic. The fix you linked to involves the |
It is also a problem when using special characters even if the lineHeight > fontSize as they get cut off. The hacky padding workaround works but is not ideal #29507 (comment) |
This is crazy, just to follow up it |
fyi: we've added a fix for this here: #46362, although we are still testing before rollout |
Closing as the PR mentioned by @mellyeliu has been merged and will be shipped with React Native 0.76 |
@mellyeliu @cortinico The issue seems to affect both Android and iOS and the PR only introduces a solution for Android. Can we reopen until iOS is also addressed? |
Reopening until iOS fix for tracking purposes |
@mellyeliu I have created a PR with a fix for iOS. Please take a moment to review It. Your feedback would be greatly appreciated! |
Description
When
lineHeight
is less than thefontSize
,Text
shrinks the line's bounding box only by removing space from above the text, rather than distributing the space evenly above and below, as is done with extra line height. Actually, the issue manifests whenlineHeight
is less thanfontSize
plus some small amount (perhaps the font bounding box height?)—e.g. <= 45px for 40px Helvetica.This leads to clipped glyphs and produces differences in text rendering between react-native-web and react-native (necolas/react-native-web#1687). After some discussion with @necolas, my inclination is that RNW's behavior is the more reasonable one, so I thought I'd open an issue here.
This issue reproduces across a variety of fonts.
Unfortunately,I worry that fixing this issue will create subtle and surprising source compatibility issues for existing clients.
React Native version:
Steps To Reproduce
Run example app here: https://snack.expo.io/W51F2OAqD
Expected Results
The extra line spacing should be removed evenly from both above and below the type.
Snack, code example, screenshot, or link to a repository:
https://snack.expo.io/W51F2OAqD
The text was updated successfully, but these errors were encountered: