diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkAdvancedTypefaceMetrics.cpp | 19 | ||||
-rw-r--r-- | src/core/SkTypeface.cpp | 11 |
2 files changed, 25 insertions, 5 deletions
diff --git a/src/core/SkAdvancedTypefaceMetrics.cpp b/src/core/SkAdvancedTypefaceMetrics.cpp index f786671c83..cff0989e31 100644 --- a/src/core/SkAdvancedTypefaceMetrics.cpp +++ b/src/core/SkAdvancedTypefaceMetrics.cpp @@ -65,6 +65,8 @@ template <typename Data, typename FontHandle> SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData( FontHandle fontHandle, int num_glyphs, + const uint32_t* subsetGlyphIDs, + uint32_t subsetGlyphIDsLength, bool (*getAdvance)(FontHandle fontHandle, int gId, Data* data)) { // Assuming that an ASCII representation of a width or a glyph id is, // on average, 3 characters long gives the following cut offs for @@ -82,10 +84,17 @@ SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData( curRange = appendRange(&result, 0); Data lastAdvance = SK_MinS16; int repeats = 0; + uint32_t subsetIndex = 0; for (int gId = 0; gId <= num_glyphs; gId++) { - Data advance; + Data advance = 0; if (gId < num_glyphs) { - SkAssertResult(getAdvance(fontHandle, gId, &advance)); + // Get glyph id only when subset is NULL, or the id is in subset. + if (!subsetGlyphIDs || + (subsetIndex < subsetGlyphIDsLength && + static_cast<uint32_t>(gId) == subsetGlyphIDs[subsetIndex])) { + SkAssertResult(getAdvance(fontHandle, gId, &advance)); + ++subsetIndex; + } } else { advance = SK_MinS16; } @@ -139,16 +148,22 @@ SkAdvancedTypefaceMetrics::AdvanceMetric<Data>* getAdvanceData( template SkAdvancedTypefaceMetrics::WidthRange* getAdvanceData( HDC hdc, int num_glyphs, + const uint32_t* subsetGlyphIDs, + uint32_t subsetGlyphIDsLength, bool (*getAdvance)(HDC hdc, int gId, int16_t* data)); #elif defined(SK_BUILD_FOR_UNIX) template SkAdvancedTypefaceMetrics::WidthRange* getAdvanceData( FT_Face face, int num_glyphs, + const uint32_t* subsetGlyphIDs, + uint32_t subsetGlyphIDsLength, bool (*getAdvance)(FT_Face face, int gId, int16_t* data)); #elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) template SkAdvancedTypefaceMetrics::WidthRange* getAdvanceData( CTFontRef ctFont, int num_glyphs, + const uint32_t* subsetGlyphIDs, + uint32_t subsetGlyphIDsLength, bool (*getAdvance)(CTFontRef ctFont, int gId, int16_t* data)); #endif template void resetRange( diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp index 82ccca5047..268fcc9af1 100644 --- a/src/core/SkTypeface.cpp +++ b/src/core/SkTypeface.cpp @@ -43,7 +43,7 @@ uint32_t SkTypeface::UniqueID(const SkTypeface* face) { // The initial value of 0 is fine, since a typeface's uniqueID should not // be zero. static uint32_t gDefaultFontID; - + if (0 == gDefaultFontID) { SkTypeface* defaultFace = SkFontHost::CreateTypeface(NULL, NULL, NULL, 0, @@ -93,6 +93,11 @@ SkTypeface* SkTypeface::Deserialize(SkStream* stream) { } SkAdvancedTypefaceMetrics* SkTypeface::getAdvancedTypefaceMetrics( - SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo) const { - return SkFontHost::GetAdvancedTypefaceMetrics(fUniqueID, perGlyphInfo); + SkAdvancedTypefaceMetrics::PerGlyphInfo perGlyphInfo, + const uint32_t* glyphIDs, + uint32_t glyphIDsCount) const { + return SkFontHost::GetAdvancedTypefaceMetrics(fUniqueID, + perGlyphInfo, + glyphIDs, + glyphIDsCount); } |