Chromium Code Reviews| Index: src/ports/SkFontHost_FreeType.cpp |
| diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp |
| index cb7ce8028dccd4e92d81b1e8ce63fc3b08c4b438..cbc3f4c8f97901ae3c33a8ed22be0e7bde4fc637 100644 |
| --- a/src/ports/SkFontHost_FreeType.cpp |
| +++ b/src/ports/SkFontHost_FreeType.cpp |
| @@ -1390,6 +1390,7 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx, |
| // pull from format-specific metrics as needed |
| SkScalar ascent, descent, leading, xmin, xmax, ymin, ymax; |
| + SkScalar underlineThickness, underlinePosition; |
| if (face->face_flags & FT_FACE_FLAG_SCALABLE) { // scalable outline font |
| ascent = -SkIntToScalar(face->ascender) / upem; |
| descent = -SkIntToScalar(face->descender) / upem; |
| @@ -1398,6 +1399,8 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx, |
| xmax = SkIntToScalar(face->bbox.xMax) / upem; |
| ymin = -SkIntToScalar(face->bbox.yMin) / upem; |
| ymax = -SkIntToScalar(face->bbox.yMax) / upem; |
| + underlineThickness = SkIntToScalar(face->underline_thickness) / upem; |
| + underlinePosition = SkIntToScalar(face->underline_position) / upem; |
|
bungeman-skia
2014/02/19 15:39:17
At this point we know that these values are truste
|
| // we may be able to synthesize x_height and cap_height from outline |
| if (!x_height) { |
| FT_BBox bbox; |
| @@ -1422,6 +1425,8 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx, |
| xmax = SkIntToScalar(face->available_sizes[fStrikeIndex].width) / xppem; |
| ymin = descent + leading; |
| ymax = ascent - descent; |
| + underlineThickness = 0; |
| + underlinePosition = 0; |
|
bungeman-skia
2014/02/19 15:39:17
At this point we know these values are not trusted
|
| } else { |
| goto ERROR; |
| } |
| @@ -1453,6 +1458,17 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx, |
| mx->fXMax = xmax; |
| mx->fXHeight = x_height; |
| mx->fCapHeight = cap_height; |
| + mx->fUnderlineThickness = underlineThickness; |
| + if(!underlineThickness) |
|
bungeman-skia
2014/02/19 15:39:17
These checks here (and below) are incorrect and th
h.joshi
2014/02/19 17:12:03
Okey, Added these checks below as "face->underline
|
| + mx->unsetFontMetricsFlag(SkPaint::FontMetrics::kUnderlineThinknessIsValid_FontMetricFlag); |
| + else |
| + mx->setFontMetricsFlag(SkPaint::FontMetrics::kUnderlineThinknessIsValid_FontMetricFlag); |
| + |
| + mx->fUnderlinePosition = underlinePosition; |
| + if(!underlinePosition) |
| + mx->unsetFontMetricsFlag(SkPaint::FontMetrics::kUnderlinePositionIsValid_FontMetricsflag); |
| + else |
| + mx->setFontMetricsFlag(SkPaint::FontMetrics::kUnderlinePositionIsValid_FontMetricsflag); |
| } |
| if (my) { |
| my->fTop = ymax * myy; |
| @@ -1465,6 +1481,17 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx, |
| my->fXMax = xmax; |
| my->fXHeight = x_height; |
| my->fCapHeight = cap_height; |
| + my->fUnderlineThickness = underlineThickness; |
| + if(!underlineThickness) |
| + my->unsetFontMetricsFlag(SkPaint::FontMetrics::kUnderlineThinknessIsValid_FontMetricFlag); |
| + else |
| + my->setFontMetricsFlag(SkPaint::FontMetrics::kUnderlineThinknessIsValid_FontMetricFlag); |
| + |
| + my->fUnderlinePosition = underlinePosition; |
| + if(!underlinePosition) |
| + my->unsetFontMetricsFlag(SkPaint::FontMetrics::kUnderlinePositionIsValid_FontMetricsflag); |
| + else |
| + my->setFontMetricsFlag(SkPaint::FontMetrics::kUnderlinePositionIsValid_FontMetricsflag); |
| } |
| } |