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 5e9d2537e5a188d88bf8b1bd186c36b50376a954..e0612bf3e7a3fd2c475a78e042d653c5ee63e200 100644 |
| --- a/ui/gfx/platform_font_win.cc |
| +++ b/ui/gfx/platform_font_win.cc |
| @@ -230,14 +230,19 @@ Font PlatformFontWin::DeriveFontWithHeight(int height, int style) { |
| } |
| return font; |
| } |
| - |
| - LOGFONT font_info; |
| - GetObject(GetNativeFont(), sizeof(LOGFONT), &font_info); |
| - font_info.lfHeight = height; |
| - SetLogFontStyle(style, &font_info); |
| - |
| - HFONT hfont = CreateFontIndirect(&font_info); |
| - return DeriveWithCorrectedSize(hfont); |
| + // We derive a font with a size delta of 0 initially, i.e the derived font |
|
msw
2015/01/12 21:30:55
Is this necessary given the early return at lines
msw
2015/01/12 21:30:55
nit: add a blank line above.
ananta
2015/01/12 22:14:15
Done.
ananta
2015/01/12 22:14:15
The function has changed.
ananta
2015/01/12 22:14:15
Removed the comment. The function has changed a bi
|
| + // starts off with the height of the current font instance. |
| + // This is to ensure that we honor the contract of this function which is |
| + // to return a font with with height less than or equal to the desired |
| + // height. |
| + Font font = DeriveFont(0, style); |
| + while (font.GetHeight() < height) { |
| + Font derived_font = font.Derive(1, style); |
|
msw
2015/01/12 21:30:55
I'm curious about the performance impact here, but
ananta
2015/01/12 22:14:15
Done. Removed the starting 2 lines which check for
|
| + if (derived_font.GetHeight() > height) |
| + break; |
| + font = derived_font; |
| + } |
| + return font; |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| @@ -518,8 +523,7 @@ PlatformFontWin::HFontRef* PlatformFontWin::CreateHFontRefFromSkia( |
| // The calculations below are similar to those in the CreateHFontRef |
| // function. The height, baseline and cap height are rounded up to ensure |
| // that they match up closely with GDI. |
| - const int height = std::ceil( |
| - skia_metrics.fDescent - skia_metrics.fAscent + skia_metrics.fLeading); |
| + const int height = std::ceil(skia_metrics.fDescent - skia_metrics.fAscent); |
| const int baseline = std::max<int>(1, std::ceil(-skia_metrics.fAscent)); |
| const int cap_height = std::ceil(paint.getTextSize() * |
| static_cast<double>(dwrite_font_metrics.capHeight) / |