Chromium Code Reviews| Index: src/core/SkPaint.cpp |
| diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp |
| index c3f217cefc60e5501e08a88755b5f537dbcb956c..cbd82758d6eb5b63474b951db03d8c673cd70a28 100644 |
| --- a/src/core/SkPaint.cpp |
| +++ b/src/core/SkPaint.cpp |
| @@ -1287,6 +1287,9 @@ SkScalar SkPaint::getFontMetrics(FontMetrics* metrics, SkScalar zoom) const { |
| paint.descriptorProc(NULL, zoomPtr, FontMetricsDescProc, metrics, true); |
| if (scale) { |
| + // Assuming Font will have correct metrics for Underline Thickness and Position |
| + metrics->fFontMetricsFlag = 0x03; |
| + |
| metrics->fTop = SkScalarMul(metrics->fTop, scale); |
| metrics->fAscent = SkScalarMul(metrics->fAscent, scale); |
| metrics->fDescent = SkScalarMul(metrics->fDescent, scale); |
| @@ -1296,6 +1299,20 @@ SkScalar SkPaint::getFontMetrics(FontMetrics* metrics, SkScalar zoom) const { |
| metrics->fXMin = SkScalarMul(metrics->fXMin, scale); |
| metrics->fXMax = SkScalarMul(metrics->fXMax, scale); |
| metrics->fXHeight = SkScalarMul(metrics->fXHeight, scale); |
| + |
| + metrics->fUnderlineThickness = SkScalarMul(metrics->fUnderlineThickness, scale); |
| + // Following is to check if we have faulty underline thciness metrics |
| + if ( (metrics->fUnderlineThickness == 0) || (metrics->fUnderlineThickness >= metrics->fAscent/2)) |
|
bungeman-skia
2014/02/17 19:10:06
Why would these checks only be done when there is
h.joshi
2014/02/18 05:48:48
Added these to check faulty font metrics for Under
|
| + { |
| + metrics->fFontMetricsFlag = metrics->fFontMetricsFlag ^ FontMetrics::kUnderlineThinknessIsValid_FontMetricFlag; |
| + } |
| + |
| + metrics->fUnderlinePosition = SkScalarMul(metrics->fUnderlinePosition, scale); |
| + // Following is to check if we have faulty underlien position metrics |
| + if(SkScalarAbs(metrics->fUnderlinePosition) >= (metrics->fDescent + metrics->fLeading)) |
| + { |
| + metrics->fFontMetricsFlag = metrics->fFontMetricsFlag ^FontMetrics::kUnderlinePositionIsValid_FontMetricsflag; |
| + } |
| } |
| return metrics->fDescent - metrics->fAscent + metrics->fLeading; |
| } |
| @@ -2257,6 +2274,14 @@ const SkRect& SkPaint::doComputeFastBounds(const SkRect& origSrc, |
| return *storage; |
| } |
| +bool SkPaint::isFontMetricsFlagSet(FontMetrics * fObject, FontMetrics::FontMetricsFlags flag) const |
| +{ |
| + if(fObject != NULL) { |
| + return SkToBool(fObject->fFontMetricsFlag & flag); |
| + } |
| + return false; |
| +} |
| + |
| #ifdef SK_DEVELOPER |
| void SkPaint::toString(SkString* str) const { |
| str->append("<dl><dt>SkPaint:</dt><dd><dl>"); |