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

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: Improvements according to the review. Created 6 years, 7 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') | no next file with comments »
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..58360ae72b7c6f4fc24bce0a4280013e287e1b9e 100644
--- a/ui/gfx/platform_font_win.cc
+++ b/ui/gfx/platform_font_win.cc
@@ -116,7 +116,20 @@ Font PlatformFontWin::DeriveFontWithHeight(int height, int style) {
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) {
msw 2014/05/29 21:34:41 Is it possible (and more efficient) to first guess
+ Font font = best_font.Derive(1, style);
+ int font_height = font.GetHeight();
+ if (font_height > height) {
+ 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698