summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-26 23:21:45 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-26 23:21:45 +0000
commit653b2a10f65a1c1bd42f22998bc9ed3a0268b88f (patch)
treed6daa813c17dcaa287771883348f770d77ce687e /skia
parent9b98c97f70bdbd19360c52af0c68672c3789446f (diff)
downloadchromium_src-653b2a10f65a1c1bd42f22998bc9ed3a0268b88f.zip
chromium_src-653b2a10f65a1c1bd42f22998bc9ed3a0268b88f.tar.gz
chromium_src-653b2a10f65a1c1bd42f22998bc9ed3a0268b88f.tar.bz2
Linux: Match the tmMaxCharWidth of Windows exactly.
The metric used is totally wrong, it's much larger than the largest advance of any glyph in the font. However, it's wrong in exactly the same way as Windows is. Review URL: http://codereview.chromium.org/12505 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6073 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r--skia/include/SkPaint.h4
-rw-r--r--skia/ports/SkFontHost_FreeType.cpp5
2 files changed, 8 insertions, 1 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