From e1b9bad0711e557e45fee109fb492d19e35e1d38 Mon Sep 17 00:00:00 2001 From: "bungeman@google.com" Date: Tue, 27 Aug 2013 21:51:37 +0000 Subject: [PATCH] Clear unknown DirectWrite font metrics. git-svn-id: http://skia.googlecode.com/svn/trunk@10963 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/ports/SkFontHost_win_dw.cpp | 40 +++++++++++++++------------------ 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/ports/SkFontHost_win_dw.cpp b/src/ports/SkFontHost_win_dw.cpp index 29cfccb044..52b2fee107 100644 --- a/src/ports/SkFontHost_win_dw.cpp +++ b/src/ports/SkFontHost_win_dw.cpp @@ -908,37 +908,33 @@ void SkScalerContext_DW::generateFontMetrics(SkPaint::FontMetrics* mx, if (!(mx || my)) return; + if (mx) { + sk_bzero(mx, sizeof(*mx)); + } + if (my) { + sk_bzero(my, sizeof(*my)); + } + DWRITE_FONT_METRICS dwfm; fTypeface->fDWriteFontFace->GetMetrics(&dwfm); + SkScalar upem = SkIntToScalar(dwfm.designUnitsPerEm); if (mx) { - mx->fTop = SkScalarMulDiv(-fRec.fTextSize, - SkIntToScalar(dwfm.ascent), - SkIntToScalar(dwfm.designUnitsPerEm)); - mx->fAscent = mx->fTop; - mx->fDescent = SkScalarMulDiv(fRec.fTextSize, - SkIntToScalar(dwfm.descent), - SkIntToScalar(dwfm.designUnitsPerEm)); - mx->fBottom = mx->fDescent; - //TODO, can be less than zero - mx->fLeading = SkScalarMulDiv(fRec.fTextSize, - SkIntToScalar(dwfm.lineGap), - SkIntToScalar(dwfm.designUnitsPerEm)); + my->fTop = -fRec.fTextSize * SkIntToScalar(dwfm.ascent) / upem; + my->fAscent = my->fTop; + my->fDescent = fRec.fTextSize * SkIntToScalar(dwfm.descent) / upem; + my->fBottom = my->fDescent; + my->fLeading = fRec.fTextSize * SkIntToScalar(dwfm.lineGap) / upem; + my->fXHeight = fRec.fTextSize * SkIntToScalar(dwfm.xHeight) / upem; } if (my) { - my->fTop = SkScalarMulDiv(-fRec.fTextSize, - SkIntToScalar(dwfm.ascent), - SkIntToScalar(dwfm.designUnitsPerEm)); + my->fTop = -fRec.fTextSize * SkIntToScalar(dwfm.ascent) / upem; my->fAscent = my->fTop; - my->fDescent = SkScalarMulDiv(fRec.fTextSize, - SkIntToScalar(dwfm.descent), - SkIntToScalar(dwfm.designUnitsPerEm)); + my->fDescent = fRec.fTextSize * SkIntToScalar(dwfm.descent) / upem; my->fBottom = my->fDescent; - //TODO, can be less than zero - my->fLeading = SkScalarMulDiv(fRec.fTextSize, - SkIntToScalar(dwfm.lineGap), - SkIntToScalar(dwfm.designUnitsPerEm)); + my->fLeading = fRec.fTextSize * SkIntToScalar(dwfm.lineGap) / upem; + my->fXHeight = fRec.fTextSize * SkIntToScalar(dwfm.xHeight) / upem; } } -- 2.34.1