diff options
Diffstat (limited to 'src/ports')
-rw-r--r-- | src/ports/SkFontHost_FreeType.cpp | 17 | ||||
-rw-r--r-- | src/ports/SkFontHost_FreeType_common.h | 3 | ||||
-rw-r--r-- | src/ports/SkFontHost_mac.cpp | 14 | ||||
-rw-r--r-- | src/ports/SkFontHost_win.cpp | 16 | ||||
-rw-r--r-- | src/ports/SkFontMgr_fontconfig.cpp | 9 | ||||
-rw-r--r-- | src/ports/SkTypeface_win_dw.cpp | 13 | ||||
-rw-r--r-- | src/ports/SkTypeface_win_dw.h | 3 |
7 files changed, 52 insertions, 23 deletions
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp index b87af6ff04..91801cdbd0 100644 --- a/src/ports/SkFontHost_FreeType.cpp +++ b/src/ports/SkFontHost_FreeType.cpp @@ -540,14 +540,17 @@ static void populate_glyph_to_unicode(FT_Face& face, SkTDArray<SkUnichar>* glyph } } -std::unique_ptr<SkAdvancedTypefaceMetrics> SkTypeface_FreeType::onGetAdvancedMetrics() const { +SkAdvancedTypefaceMetrics* SkTypeface_FreeType::onGetAdvancedTypefaceMetrics( + PerGlyphInfo perGlyphInfo, + const uint32_t* glyphIDs, + uint32_t glyphIDsCount) const { AutoFTAccess fta(this); FT_Face face = fta.face(); if (!face) { return nullptr; } - std::unique_ptr<SkAdvancedTypefaceMetrics> info(new SkAdvancedTypefaceMetrics); + SkAdvancedTypefaceMetrics* info = new SkAdvancedTypefaceMetrics; info->fFontName.set(FT_Get_Postscript_Name(face)); if (FT_HAS_MULTIPLE_MASTERS(face)) { @@ -647,9 +650,13 @@ std::unique_ptr<SkAdvancedTypefaceMetrics> SkTypeface_FreeType::onGetAdvancedMet info->fBBox = SkIRect::MakeLTRB(face->bbox.xMin, face->bbox.yMax, face->bbox.xMax, face->bbox.yMin); - bool perGlyphInfo = FT_IS_SCALABLE(face); + if (!FT_IS_SCALABLE(face)) { + perGlyphInfo = kNo_PerGlyphInfo; + } - if (perGlyphInfo && info->fType == SkAdvancedTypefaceMetrics::kType1_Font) { + if (perGlyphInfo & kGlyphNames_PerGlyphInfo && + info->fType == SkAdvancedTypefaceMetrics::kType1_Font) + { // Postscript fonts may contain more than 255 glyphs, so we end up // using multiple font descriptions with a glyph ordering. Record // the name of each glyph. @@ -661,7 +668,7 @@ std::unique_ptr<SkAdvancedTypefaceMetrics> SkTypeface_FreeType::onGetAdvancedMet } } - if (perGlyphInfo && + if (perGlyphInfo & kToUnicode_PerGlyphInfo && info->fType != SkAdvancedTypefaceMetrics::kType1_Font && face->num_charmaps) { diff --git a/src/ports/SkFontHost_FreeType_common.h b/src/ports/SkFontHost_FreeType_common.h index 5270745581..b9e8b13d7f 100644 --- a/src/ports/SkFontHost_FreeType_common.h +++ b/src/ports/SkFontHost_FreeType_common.h @@ -80,7 +80,8 @@ protected: virtual SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&, const SkDescriptor*) const override; void onFilterRec(SkScalerContextRec*) const override; - std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override; + SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( + PerGlyphInfo, const uint32_t*, uint32_t) const override; int onGetUPEM() const override; bool onGetKerningPairAdjustments(const uint16_t glyphs[], int count, int32_t adjustments[]) const override; diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp index 92334cb6bc..a43cf22c98 100644 --- a/src/ports/SkFontHost_mac.cpp +++ b/src/ports/SkFontHost_mac.cpp @@ -526,7 +526,8 @@ protected: const SkDescriptor*) const override; void onFilterRec(SkScalerContextRec*) const override; void onGetFontDescriptor(SkFontDescriptor*, bool*) const override; - std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override; + SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( + PerGlyphInfo, const uint32_t* glyphIDs, uint32_t glyphIDsCount) const override; int onCharsToGlyphs(const void* chars, Encoding, uint16_t glyphs[], int glyphCount) const override; int onCountGlyphs() const override; @@ -1490,14 +1491,17 @@ static void CFStringToSkString(CFStringRef src, SkString* dst) { dst->resize(strlen(dst->c_str())); } -std::unique_ptr<SkAdvancedTypefaceMetrics> SkTypeface_Mac::onGetAdvancedMetrics() const { +SkAdvancedTypefaceMetrics* SkTypeface_Mac::onGetAdvancedTypefaceMetrics( + PerGlyphInfo perGlyphInfo, + const uint32_t* glyphIDs, + uint32_t glyphIDsCount) const { AUTO_CG_LOCK(); UniqueCFRef<CTFontRef> ctFont = ctfont_create_exact_copy(fFontRef.get(), CTFontGetUnitsPerEm(fFontRef.get()), nullptr); - std::unique_ptr<SkAdvancedTypefaceMetrics> info(new SkAdvancedTypefaceMetrics); + SkAdvancedTypefaceMetrics* info = new SkAdvancedTypefaceMetrics; { UniqueCFRef<CFStringRef> fontName(CTFontCopyPostScriptName(ctFont.get())); @@ -1520,7 +1524,9 @@ std::unique_ptr<SkAdvancedTypefaceMetrics> SkTypeface_Mac::onGetAdvancedMetrics( CFIndex glyphCount = CTFontGetGlyphCount(ctFont.get()); - populate_glyph_to_unicode(ctFont.get(), glyphCount, &info->fGlyphToUnicode); + if (perGlyphInfo & kToUnicode_PerGlyphInfo) { + populate_glyph_to_unicode(ctFont.get(), glyphCount, &info->fGlyphToUnicode); + } // If it's not a truetype font, mark it as 'other'. Assume that TrueType // fonts always have both glyf and loca tables. At the least, this is what diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp index 4a0aabede9..25c608878d 100644 --- a/src/ports/SkFontHost_win.cpp +++ b/src/ports/SkFontHost_win.cpp @@ -259,7 +259,8 @@ protected: SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&, const SkDescriptor*) const override; void onFilterRec(SkScalerContextRec*) const override; - std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override; + SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( + PerGlyphInfo, const uint32_t*, uint32_t) const override; void onGetFontDescriptor(SkFontDescriptor*, bool*) const override; int onCharsToGlyphs(const void* chars, Encoding encoding, uint16_t glyphs[], int glyphCount) const override; @@ -1724,9 +1725,12 @@ void LogFontTypeface::onGetFontDescriptor(SkFontDescriptor* desc, *isLocalStream = this->fSerializeAsStream; } -std::unique_ptr<SkAdvancedTypefaceMetrics> LogFontTypeface::onGetAdvancedMetrics() const { +SkAdvancedTypefaceMetrics* LogFontTypeface::onGetAdvancedTypefaceMetrics( + PerGlyphInfo perGlyphInfo, + const uint32_t* glyphIDs, + uint32_t glyphIDsCount) const { LOGFONT lf = fLogFont; - std::unique_ptr<SkAdvancedTypefaceMetrics> info(nullptr); + SkAdvancedTypefaceMetrics* info = nullptr; HDC hdc = CreateCompatibleDC(nullptr); HFONT font = CreateFontIndirect(&lf); @@ -1756,7 +1760,7 @@ std::unique_ptr<SkAdvancedTypefaceMetrics> LogFontTypeface::onGetAdvancedMetrics } glyphCount = calculateGlyphCount(hdc, fLogFont); - info.reset(new SkAdvancedTypefaceMetrics); + info = new SkAdvancedTypefaceMetrics; tchar_to_skstring(lf.lfFaceName, &info->fFontName); // If bit 1 is set, the font may not be embedded in a document. // If bit 1 is clear, the font can be embedded. @@ -1765,7 +1769,9 @@ std::unique_ptr<SkAdvancedTypefaceMetrics> LogFontTypeface::onGetAdvancedMetrics info->fFlags |= SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag; } - populate_glyph_to_unicode(hdc, glyphCount, &(info->fGlyphToUnicode)); + if (perGlyphInfo & kToUnicode_PerGlyphInfo) { + populate_glyph_to_unicode(hdc, glyphCount, &(info->fGlyphToUnicode)); + } if (glyphCount > 0 && (otm.otmTextMetrics.tmPitchAndFamily & TMPF_TRUETYPE)) { diff --git a/src/ports/SkFontMgr_fontconfig.cpp b/src/ports/SkFontMgr_fontconfig.cpp index be4b17dd12..f27ad40da6 100644 --- a/src/ports/SkFontMgr_fontconfig.cpp +++ b/src/ports/SkFontMgr_fontconfig.cpp @@ -489,9 +489,12 @@ public: this->INHERITED::onFilterRec(rec); } - std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override { - std::unique_ptr<SkAdvancedTypefaceMetrics> info = - this->INHERITED::onGetAdvancedMetrics(); + SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(PerGlyphInfo perGlyphInfo, + const uint32_t* glyphIDs, + uint32_t glyphIDsCount) const override + { + SkAdvancedTypefaceMetrics* info = + this->INHERITED::onGetAdvancedTypefaceMetrics(perGlyphInfo, glyphIDs, glyphIDsCount); // Simulated fonts shouldn't be considered to be of the type of their data. if (get_matrix(fPattern, FC_MATRIX) || get_bool(fPattern, FC_EMBOLDEN)) { diff --git a/src/ports/SkTypeface_win_dw.cpp b/src/ports/SkTypeface_win_dw.cpp index fe20cc9699..ae4e3f7105 100644 --- a/src/ports/SkTypeface_win_dw.cpp +++ b/src/ports/SkTypeface_win_dw.cpp @@ -319,9 +319,12 @@ static void populate_glyph_to_unicode(IDWriteFontFace* fontFace, SkTDArray<SkUnichar>(glyphToUni, maxGlyph + 1).swap(*glyphToUnicode); } -std::unique_ptr<SkAdvancedTypefaceMetrics> DWriteFontTypeface::onGetAdvancedMetrics() const { +SkAdvancedTypefaceMetrics* DWriteFontTypeface::onGetAdvancedTypefaceMetrics( + PerGlyphInfo perGlyphInfo, + const uint32_t* glyphIDs, + uint32_t glyphIDsCount) const { - std::unique_ptr<SkAdvancedTypefaceMetrics> info(nullptr); + SkAdvancedTypefaceMetrics* info = nullptr; HRESULT hr = S_OK; @@ -330,7 +333,7 @@ std::unique_ptr<SkAdvancedTypefaceMetrics> DWriteFontTypeface::onGetAdvancedMetr DWRITE_FONT_METRICS dwfm; fDWriteFontFace->GetMetrics(&dwfm); - info.reset(new SkAdvancedTypefaceMetrics); + info = new SkAdvancedTypefaceMetrics; info->fAscent = SkToS16(dwfm.ascent); info->fDescent = SkToS16(dwfm.descent); @@ -350,7 +353,9 @@ std::unique_ptr<SkAdvancedTypefaceMetrics> DWriteFontTypeface::onGetAdvancedMetr hr = sk_wchar_to_skstring(familyName.get(), familyNameLen, &info->fFontName); - populate_glyph_to_unicode(fDWriteFontFace.get(), glyphCount, &(info->fGlyphToUnicode)); + if (perGlyphInfo & kToUnicode_PerGlyphInfo) { + populate_glyph_to_unicode(fDWriteFontFace.get(), glyphCount, &(info->fGlyphToUnicode)); + } DWRITE_FONT_FACE_TYPE fontType = fDWriteFontFace->GetType(); if (fontType != DWRITE_FONT_FACE_TYPE_TRUETYPE && diff --git a/src/ports/SkTypeface_win_dw.h b/src/ports/SkTypeface_win_dw.h index 7abbde55aa..d7c73e2697 100644 --- a/src/ports/SkTypeface_win_dw.h +++ b/src/ports/SkTypeface_win_dw.h @@ -104,7 +104,8 @@ protected: SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&, const SkDescriptor*) const override; void onFilterRec(SkScalerContextRec*) const override; - std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override; + SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics( + PerGlyphInfo, const uint32_t*, uint32_t) const override; void onGetFontDescriptor(SkFontDescriptor*, bool*) const override; int onCharsToGlyphs(const void* chars, Encoding encoding, uint16_t glyphs[], int glyphCount) const override; |