Chromium Code Reviews| Index: ui/gfx/platform_font_mac.mm |
| diff --git a/ui/gfx/platform_font_mac.mm b/ui/gfx/platform_font_mac.mm |
| index 892d2ea66d8a0be0b501b838a07516bfd5e5c0d7..008c4d049f11d8c58695a5d2a517f1ac59948263 100644 |
| --- a/ui/gfx/platform_font_mac.mm |
| +++ b/ui/gfx/platform_font_mac.mm |
| @@ -166,11 +166,18 @@ void PlatformFontMac::CalculateMetricsAndInitRenderParams() { |
| return; |
| } |
| - base::scoped_nsobject<NSLayoutManager> layout_manager( |
| - [[NSLayoutManager alloc] init]); |
| - height_ = SkScalarCeilToInt([layout_manager defaultLineHeightForFont:font]); |
| - ascent_ = SkScalarCeilToInt([font ascender]); |
| - cap_height_ = SkScalarCeilToInt([font capHeight]); |
| + ascent_ = ceil([font ascender]); |
|
tapted
2015/07/27 03:58:57
note I ditched SkScalarCeilToInt here, just becaus
|
| + cap_height_ = ceil([font capHeight]); |
| + |
| + // PlatformFontMac once used -[NSLayoutManager defaultLineHeightForFont:] to |
| + // initialize |height_|. However, it has a silly rounding bug. Essentially, it |
| + // gives round(ascent) + round(descent). E.g. Helvetica Neue at size 16 gives |
| + // ascent=15.4634, descent=3.38208 -> 15 + 3 = 18. When the height should be |
| + // at least 19. According to the OpenType specification, these values should |
| + // simply be added, so do that. Note this uses the already-rounded |ascent_| |
| + // to ensure GetBaseline() + descender fits within GetHeight() during layout. |
| + height_ = ceil(ascent_ + std::abs([font descender]) + [font leading]); |
| + |
| average_width_ = |
| NSWidth([font boundingRectForGlyph:[font glyphWithName:@"x"]]); |