Add maxCharWidth and a compile flag to use old metrics (needed by Blink).

Review URL: https://codereview.chromium.org/17502006

git-svn-id: http://skia.googlecode.com/svn/trunk@9712 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bungeman@google.com 2013-06-21 05:31:38 +00:00
parent 45a3071498
commit e9d8319576
2 changed files with 14 additions and 0 deletions

View File

@ -714,6 +714,7 @@ public:
SkScalar fBottom; //!< The greatest distance below the baseline for any glyph (will be >= 0)
SkScalar fLeading; //!< The recommended distance to add between lines of text (will be >= 0)
SkScalar fAvgCharWidth; //!< the average charactor width (>= 0)
SkScalar fMaxCharWidth; //!< the max charactor width (>= 0)
SkScalar fXMin; //!< The minimum bounding box x value for all glyphs
SkScalar fXMax; //!< The maximum bounding box x value for all glyphs
SkScalar fXHeight; //!< the height of an 'x' in px, or 0 if no 'x' in face

View File

@ -839,7 +839,9 @@ void SkScalerContext_Windows::generateFontMetrics(SkPaint::FontMetrics* mx, SkPa
SkASSERT(fDDC);
#ifndef SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS
if (fType == SkScalerContext_Windows::kBitmap_Type) {
#endif
if (mx) {
mx->fTop = SkIntToScalar(-fTM.tmAscent);
mx->fAscent = SkIntToScalar(-fTM.tmAscent);
@ -855,9 +857,15 @@ void SkScalerContext_Windows::generateFontMetrics(SkPaint::FontMetrics* mx, SkPa
my->fBottom = SkIntToScalar(fTM.tmDescent);
my->fLeading = SkIntToScalar(fTM.tmExternalLeading);
my->fAvgCharWidth = SkIntToScalar(fTM.tmAveCharWidth);
my->fMaxCharWidth = SkIntToScalar(fTM.tmMaxCharWidth);
my->fXMin = 0;
my->fXMax = my->fMaxCharWidth;
//my->fXHeight = 0;
}
#ifndef SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS
return;
}
#endif
OUTLINETEXTMETRIC otm;
@ -879,12 +887,17 @@ void SkScalerContext_Windows::generateFontMetrics(SkPaint::FontMetrics* mx, SkPa
}
if (my) {
#ifndef SK_GDI_ALWAYS_USE_TEXTMETRICS_FOR_FONT_METRICS
my->fTop = -fScale * otm.otmrcFontBox.top;
my->fAscent = -fScale * otm.otmAscent;
my->fDescent = -fScale * otm.otmDescent;
my->fBottom = -fScale * otm.otmrcFontBox.bottom;
my->fLeading = fScale * otm.otmLineGap;
my->fAvgCharWidth = fScale * otm.otmTextMetrics.tmAveCharWidth;
my->fMaxCharWidth = fScale * otm.otmTextMetrics.tmMaxCharWidth;
my->fXMin = fScale * otm.otmrcFontBox.left;
my->fXMax = fScale * otm.otmrcFontBox.right;
#endif
my->fXHeight = fScale * otm.otmsXHeight;
}
}