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

Unified Diff: ui/gfx/render_text.cc

Issue 66723009: Fixes 1 pixel shift of text rendering on CrOS and Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 2c062a5555d355965da55061f17206d9de6bc439..b35e1dcfe525da4fb8103062756e9ee8759c5367 100644
--- a/ui/gfx/render_text.cc
+++ b/ui/gfx/render_text.cc
@@ -62,8 +62,13 @@ int DetermineBaselineCenteringText(const Rect& display_rect,
const int baseline = font_list.GetBaseline();
const int cap_height = font_list.GetCapHeight();
const int internal_leading = baseline - cap_height;
- const int baseline_shift =
- (display_height - cap_height) / 2 - internal_leading;
+ // Some platforms don't support getting the cap height, and simply return
msw 2013/11/11 18:07:26 This and your prior CL (http://crrev.com/59873002)
+ // the entire font ascent from GetCapHeight(). Centering the ascent makes
+ // the font look too low, so if GetCapHeight() returns the ascent, center
+ // the entire font height instead.
+ const int space =
+ display_height - ((internal_leading != 0) ? cap_height : font_height);
+ const int baseline_shift = space / 2 - internal_leading;
return baseline + std::max(min_shift, std::min(max_shift, baseline_shift));
}
« 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