diff options
-rw-r--r-- | skia/include/SkPaint.h | 4 | ||||
-rw-r--r-- | skia/ports/SkFontHost_FreeType.cpp | 5 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/FontCacheLinux.cpp | 2 | ||||
-rw-r--r-- | webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp | 3 |
4 files changed, 10 insertions, 4 deletions
diff --git a/skia/include/SkPaint.h b/skia/include/SkPaint.h index 921245b..9529dd0 100644 --- a/skia/include/SkPaint.h +++ b/skia/include/SkPaint.h @@ -588,6 +588,10 @@ public: SkScalar fLeading; //!< The recommended distance to add between lines of text (will be >= 0) SkScalar fHeight; //!< the vertical distance between two consecutive baselines (>= 0) SkScalar fAvgCharWidth; //!< the average charactor width (>= 0) + SkScalar fXRange; //!< This is the maximum range of X bounding box points + // in units of em. It's used to calculate a value which + // matches Windows's GetTextMetrics tmMaxCharWidth + // member exactly. // VDMX values are exact ascent and descent values for scalable fonts at // a certain pixel size. diff --git a/skia/ports/SkFontHost_FreeType.cpp b/skia/ports/SkFontHost_FreeType.cpp index 3011811..46c86b6 100644 --- a/skia/ports/SkFontHost_FreeType.cpp +++ b/skia/ports/SkFontHost_FreeType.cpp @@ -792,6 +792,7 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx, SkP SkFixed scaleY = fScaleY; SkFixed mxy = fMatrix22.xy; SkFixed myy = fMatrix22.yy; + SkScalar xrange = static_cast<SkScalar>(face->bbox.xMax - face->bbox.xMin) / upem; int leading = face->height - face->ascender + face->descender; if (leading < 0) @@ -817,7 +818,7 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx, SkP y = SkFixedMul(myy, y); pts[i].set(SkFixedToScalar(x), SkFixedToScalar(y)); } - + if (mx) { mx->fTop = pts[0].fX; @@ -827,6 +828,7 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx, SkP mx->fLeading = pts[4].fX; mx->fHeight = pts[5].fX; mx->fAvgCharWidth = pts[6].fX; + mx->fXRange = xrange; // The VDMX metrics only make sense in the horizontal direction // I believe @@ -841,6 +843,7 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx, SkP my->fLeading = pts[4].fY; my->fHeight = pts[5].fY; my->fAvgCharWidth = pts[6].fY; + my->fXRange = xrange; my->fVDMXMetricsValid = false; // Attempt to parse the VDMX table to get exact metrics diff --git a/webkit/port/platform/graphics/chromium/FontCacheLinux.cpp b/webkit/port/platform/graphics/chromium/FontCacheLinux.cpp index ab37374..b9aa718 100644 --- a/webkit/port/platform/graphics/chromium/FontCacheLinux.cpp +++ b/webkit/port/platform/graphics/chromium/FontCacheLinux.cpp @@ -96,7 +96,7 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD style |= SkTypeface::kItalic; SkTypeface* tf = SkTypeface::Create(name, (SkTypeface::Style)style); - + FontPlatformData* result = new FontPlatformData(tf, fontDescription.computedSize(), diff --git a/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp b/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp index 7b8a75e..c5080c9 100644 --- a/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp +++ b/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp @@ -52,8 +52,7 @@ void SimpleFontData::platformInit() if (!glyphPageZero) return; - static const UChar32 M_char = 'M'; - m_maxCharWidth = widthForGlyph(glyphPageZero->glyphDataForCharacter(M_char).glyph); + m_maxCharWidth = SkScalarRound(metrics.fXRange * SkScalarRound(m_font.size())); if (metrics.fAvgCharWidth) { m_avgCharWidth = SkScalarRound(metrics.fAvgCharWidth); |