MultiLine RenderTextHarfBuzz doesn't vertically centre text on each line when min_line_height() != Font::GetHeight() |
|||
Issue description
... a single-line views::Label will correctly do this (as will RenderTextMac which is "always" single line). But RTHB's "native" multiline support will always align text to the top of the Label.
Chrome Version : 58.0.3029.19
OS Version: OS X 10.12.3
What steps will reproduce the problem?
1. Use Label::SetLineHeight()
What is the expected result?
Expect text to be vertically cenetred
What happens instead of that?
Aligns vertically to the top (except when single line).
There is a TODO..
// TODO(ckocagil): Add vertical alignment and line spacing support instead.
int min_line_height() const { return min_line_height_; }
void SetMinLineHeight(int line_height);
But it's not really documented what the default vertical alignment should be.
To fix, I think we can look to HarfBuzzLineBreaker. It has a |min_baseline| argument, which currently always takes Font::GetHeight(). If we instead pass DetermineBaselineCenteringText(line_height(), font_list()) (from render_text.cc), then we get centred vertical alignment.
DetermineBaselineCenteringText() is currently used to centre a single line in the display rectangle.
This suggests that callers of RenderText currently assume text is centred vertically. That is, creating text with a larger bounding box than it needs will centre text vertically -- if a caller assuming that behaviour is also using SetLineHeight(), then the text would no longer be properly centred with the current behaviour.
Said another way, I don't think currently we have a use-case for vertical alignment that isn't centred. So rather than making it adjsutable, I think we can just always centre.
Started -> https://codereview.chromium.org/2767163003
,
Mar 23 2017
I agree with your assessment; always using DetermineBaselineCenteringText sgtm
,
Mar 31 2017
https://codereview.chromium.org/2767163003/ out for review (found a good way to test this - it's tricky since a lot depends on font metrics)
,
Apr 3 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/9ec27b9e456d7d7f4899a2d9e7dc4efd8a1d1e5b commit 9ec27b9e456d7d7f4899a2d9e7dc4efd8a1d1e5b Author: tapted <tapted@chromium.org> Date: Mon Apr 03 02:27:55 2017 Vertically center multi-line RenderTextHarfBuzz that uses SetMinLineHeight(). Currently the text is only vertically centered in the non-multi-line case. Test by comparing the effect of increasing the display rectangle versus increasing the line height. These should behave the same, except in the latter case the selection highlight should also increase in height. BUG= 704404 Review-Url: https://codereview.chromium.org/2767163003 Cr-Commit-Position: refs/heads/master@{#461361} [modify] https://crrev.com/9ec27b9e456d7d7f4899a2d9e7dc4efd8a1d1e5b/ui/gfx/render_text.cc [modify] https://crrev.com/9ec27b9e456d7d7f4899a2d9e7dc4efd8a1d1e5b/ui/gfx/render_text.h [modify] https://crrev.com/9ec27b9e456d7d7f4899a2d9e7dc4efd8a1d1e5b/ui/gfx/render_text_harfbuzz.cc [modify] https://crrev.com/9ec27b9e456d7d7f4899a2d9e7dc4efd8a1d1e5b/ui/gfx/render_text_unittest.cc
,
Apr 3 2017
|
|||
►
Sign in to add a comment |
|||
Comment 1 by tapted@chromium.org
, Mar 23 201717.0 KB
17.0 KB View Download
187 KB
187 KB View Download
184 KB
184 KB View Download
552 KB
552 KB View Download
549 KB
549 KB View Download