New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 704404 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Chrome , Mac
Pri: 1
Type: Bug

Blocking:
issue 691891



Sign in to add a comment

MultiLine RenderTextHarfBuzz doesn't vertically centre text on each line when min_line_height() != Font::GetHeight()

Project Member Reported by tapted@chromium.org, Mar 23 2017

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
 

Comment 1 by tapted@chromium.org, Mar 23 2017

harfbuzz_multi_line_nohighlight.png
17.0 KB View Download
harfbuzz_multi_line.png
187 KB View Download
harfbuzz_single_line.png
184 KB View Download
render_text_harfbuzz.png
552 KB View Download
render_text_mac.png
549 KB View Download

Comment 2 by msw@chromium.org, Mar 23 2017

I agree with your assessment; always using DetermineBaselineCenteringText sgtm

Comment 3 by tapted@chromium.org, Mar 31 2017

Labels: OS-Chrome OS-Linux OS-Windows
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)
Project Member

Comment 4 by bugdroid1@chromium.org, 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

Status: Fixed (was: Started)

Sign in to add a comment