Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1905)

Unified Diff: ui/gfx/render_text.cc

Issue 2948033003: Vertically center the cap height of multi-line text.
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text.cc
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
index dfac16495193edac4772265f9f6903c821d1d734..830bbd120c7852cdb2c9212ea8918f90cc6604a3 100644
--- a/ui/gfx/render_text.cc
+++ b/ui/gfx/render_text.cc
@@ -1203,9 +1203,12 @@ Vector2d RenderText::GetAlignmentOffset(size_t line_number) {
// Vertically center the text.
if (multiline_) {
- const int text_height = lines_.back().preceding_heights +
- lines_.back().size.height();
- offset.set_y((display_rect_.height() - text_height) / 2);
+ const int line_height = lines_.back().size.height();
+ const int text_height = lines_.back().preceding_heights + line_height;
+ const int extra_space = display_rect_.height() - text_height;
+ const int centering_baseline =
+ DetermineBaselineCenteringText(line_height + extra_space, font_list());
+ offset.set_y(centering_baseline - GetDisplayTextBaseline());
} else {
offset.set_y(GetBaseline() - GetDisplayTextBaseline());
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698