-
Notifications
You must be signed in to change notification settings - Fork 29.5k
Add TextLeadingDistribution to TextStyle #77001
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
Add TextLeadingDistribution to TextStyle #77001
Conversation
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The approach LGTM. I mentioned tests and docs in my comments but it seems like maybe you're planning to come back to that.
| // TODO(LongCatIsLooong): web support for | ||
| // https://github.com/flutter/flutter/issues/72521 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you or MH come up with a plan on how to do this? Hopefully it will now map closely to what CSS does with leading and line-height.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh and is it documented anywhere that leadingDistribution has no effect on web right now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed that you wrote that you plan to update the documentation later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the canvaskit backend is now the default. Not sure how this can be done with the css backend. I'll come back to the documentation when I start working on the web part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Well it should be much easier on the canvaskit backend, and it should end up working closely to how CSS does it anyway since this half leading approach came from the CSS spec as I understand it.
| expect( | ||
| style.apply(leadingDistribution: TextLeadingDistribution.proportional).leadingDistribution, | ||
| TextLeadingDistribution.proportional, | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you actually test the effect of leadingDistribution in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested that in the engine repo but doing basic e2e tests sounds like a good idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that's right 👍
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does the 1 come from? I was expecting a 0.1 from the height.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added to the comment that the height multiplier does not scale the glyph only the line-height.
46a651e to
f4ee84a
Compare
| import 'dart:ui' as ui show TextStyle, ParagraphStyle, FontFeature, Shadow; | ||
|
|
||
| import 'package:flutter/painting.dart'; | ||
| import 'package:flutter/src/foundation/constants.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, it should just be enough to import package:flutter/foundation.dart
@goderbauer don't we have a lint that should have caught this? Or does it not apply to tests?
Engine PR: flutter/engine#24668
With minimal documentation. I'll expand the documentation later with images. Things to explain:
StrutStyleorTextStyle.TextHeightBehavior's leading trim affects the line-height.List which issues are fixed by this PR. You must list at least one issue.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.