Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(978)

Unified Diff: src/ports/SkTypeface_win_dw.cpp

Issue 2333423002: Simulated fonts aren't TrueType fonts. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Also FontConfig. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ports/SkFontMgr_fontconfig.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkTypeface_win_dw.cpp
diff --git a/src/ports/SkTypeface_win_dw.cpp b/src/ports/SkTypeface_win_dw.cpp
index 348bc9f81e46002a42be807feec4a25bd1c51861..220f21b19d0b7432f3c9483c09a697b2102f29c5 100644
--- a/src/ports/SkTypeface_win_dw.cpp
+++ b/src/ports/SkTypeface_win_dw.cpp
@@ -331,6 +331,10 @@ SkAdvancedTypefaceMetrics* DWriteFontTypeface::onGetAdvancedTypefaceMetrics(
info->fEmSize = dwfm.designUnitsPerEm;
info->fLastGlyphID = SkToU16(glyphCount - 1);
+ info->fAscent = SkToS16(dwfm.ascent);
+ info->fDescent = SkToS16(dwfm.descent);
+ info->fCapHeight = SkToS16(dwfm.capHeight);
+
// SkAdvancedTypefaceMetrics::fFontName is in theory supposed to be
// the PostScript name of the font. However, due to the way it is currently
// used, it must actually be a family name.
@@ -350,24 +354,22 @@ SkAdvancedTypefaceMetrics* DWriteFontTypeface::onGetAdvancedTypefaceMetrics(
}
DWRITE_FONT_FACE_TYPE fontType = fDWriteFontFace->GetType();
- if (fontType == DWRITE_FONT_FACE_TYPE_TRUETYPE ||
- fontType == DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION) {
- info->fType = SkAdvancedTypefaceMetrics::kTrueType_Font;
- } else {
- info->fAscent = dwfm.ascent;
- info->fDescent = dwfm.descent;
- info->fCapHeight = dwfm.capHeight;
+ if (fontType != DWRITE_FONT_FACE_TYPE_TRUETYPE &&
+ fontType != DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION)
+ {
return info;
}
+ // Simulated fonts aren't really TrueType fonts.
+ if (fDWriteFontFace->GetSimulations() == DWRITE_FONT_SIMULATIONS_NONE) {
+ info->fType = SkAdvancedTypefaceMetrics::kTrueType_Font;
+ }
+
AutoTDWriteTable<SkOTTableHead> headTable(fDWriteFontFace.get());
AutoTDWriteTable<SkOTTablePostScript> postTable(fDWriteFontFace.get());
AutoTDWriteTable<SkOTTableHorizontalHeader> hheaTable(fDWriteFontFace.get());
AutoTDWriteTable<SkOTTableOS2> os2Table(fDWriteFontFace.get());
if (!headTable.fExists || !postTable.fExists || !hheaTable.fExists || !os2Table.fExists) {
- info->fAscent = dwfm.ascent;
- info->fDescent = dwfm.descent;
- info->fCapHeight = dwfm.capHeight;
return info;
}
@@ -406,10 +408,6 @@ SkAdvancedTypefaceMetrics* DWriteFontTypeface::onGetAdvancedTypefaceMetrics(
info->fItalicAngle = SkEndian_SwapBE32(postTable->italicAngle) >> 16;
- info->fAscent = SkToS16(dwfm.ascent);
- info->fDescent = SkToS16(dwfm.descent);
- info->fCapHeight = SkToS16(dwfm.capHeight);
-
info->fBBox = SkIRect::MakeLTRB((int32_t)SkEndian_SwapBE16((uint16_t)headTable->xMin),
(int32_t)SkEndian_SwapBE16((uint16_t)headTable->yMax),
(int32_t)SkEndian_SwapBE16((uint16_t)headTable->xMax),
« no previous file with comments | « src/ports/SkFontMgr_fontconfig.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698