Chromium Code Reviews| 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; |
| } |
| //////////////////////////////////////////////////////////////////////////////// |