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

Unified Diff: ui/gfx/platform_font_win.cc

Issue 251773002: PlatformFontWin::DeriveFontWithHeight insensitive to base font's height (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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 | ui/gfx/platform_font_win_unittest.cc » ('j') | ui/gfx/platform_font_win_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/platform_font_win.cc
diff --git a/ui/gfx/platform_font_win.cc b/ui/gfx/platform_font_win.cc
index 4acaf64b34abdb2ff9abb8b0755e588741f8f1e1..bd835a5798d01c58150266a44eda979644806cd1 100644
--- a/ui/gfx/platform_font_win.cc
+++ b/ui/gfx/platform_font_win.cc
@@ -112,11 +112,23 @@ Font PlatformFontWin::DeriveFontWithHeight(int height, int style) {
LOGFONT font_info;
GetObject(GetNativeFont(), sizeof(LOGFONT), &font_info);
- font_info.lfHeight = height;
SetLogFontStyle(style, &font_info);
HFONT hfont = CreateFontIndirect(&font_info);
- return Font(new PlatformFontWin(CreateHFontRef(hfont)));
+ Font best_font(new PlatformFontWin(CreateHFontRef(hfont)));
+ int best_font_height = best_font.GetHeight();
+
+ while (best_font_height <= height) {
+ Font font = best_font.Derive(1, style);
+ int font_height = font.GetHeight();
+ if (font_height > height) {
Alexei Svitkine (slow) 2014/04/25 15:56:14 I'm not sure this if is needed, since the loop sho
Tomasz Moniuszko 2014/05/08 14:08:17 The reason for this fix is that GetTextMetrics ret
Alexei Svitkine (slow) 2014/05/09 21:17:50 I see, that makes sense since we iterate down in o
Tomasz Moniuszko 2014/05/29 10:46:40 Done. Test results for 100k repeats with differen
Alexei Svitkine (slow) 2014/05/29 21:13:34 Seems like a sizeable-enough win to do the optimiz
+ break;
+ }
+ best_font = font;
+ best_font_height = font_height;
+ }
+
+ return best_font;
}
////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « no previous file | ui/gfx/platform_font_win_unittest.cc » ('j') | ui/gfx/platform_font_win_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698