diff options
author | bungeman <bungeman@google.com> | 2015-03-19 10:43:57 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-19 10:43:57 -0700 |
commit | 665b038b5745a9f5dc88b7ccfb39466a4c8750bf (patch) | |
tree | c4be2a8d3f7f53f65b112630f3619c007d864100 /src | |
parent | f87cbcdf9f10120ca1821b4d6de94f7a2e94f930 (diff) |
Use typographic font metrics when the font requests.
FreeType always returns the 'hhea' font metrics for ascent and descent,
and ignores the 'OS/2'::fsSelection::UseTypoMetrics bit. (It also
ignores the VDMX table, which makes this change correct.) This change
uses the typographic font metrics when the font requests their use.
Review URL: https://codereview.chromium.org/1020643002
Diffstat (limited to 'src')
-rw-r--r-- | src/ports/SkFontHost_FreeType.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index f462e1e142..19aed66a5c 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -1315,9 +1315,20 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* metrics 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; - leading = SkIntToScalar(face->height + (face->descender - face->ascender)) / upem; + // FreeType will always use HHEA metrics if they're not zero. + // It completely ignores the OS/2 fsSelection::UseTypoMetrics bit. + // It also ignores the VDMX tables, which are also of interest here + // (and override everything else when they apply). + static const int kUseTypoMetricsMask = (1 << 7); + if (os2 && os2->version != 0xFFFF && (os2->fsSelection & kUseTypoMetricsMask)) { + ascent = -SkIntToScalar(os2->sTypoAscender) / upem; + descent = -SkIntToScalar(os2->sTypoDescender) / upem; + leading = SkIntToScalar(os2->sTypoLineGap) / upem; + } else { + ascent = -SkIntToScalar(face->ascender) / upem; + descent = -SkIntToScalar(face->descender) / upem; + leading = SkIntToScalar(face->height + (face->descender - face->ascender)) / upem; + } xmin = SkIntToScalar(face->bbox.xMin) / upem; xmax = SkIntToScalar(face->bbox.xMax) / upem; ymin = -SkIntToScalar(face->bbox.yMin) / upem; |