Index: src/pdf/SkPDFFont.h |
diff --git a/src/pdf/SkPDFFont.h b/src/pdf/SkPDFFont.h |
index 27f1b5bfe3c35e169b1be72d2fca30516f32460d..c8156216c73d9f1e010e3c619453a532a1d5e462 100644 |
--- a/src/pdf/SkPDFFont.h |
+++ b/src/pdf/SkPDFFont.h |
@@ -139,6 +139,17 @@ public: |
*/ |
virtual SkPDFFont* getFontSubset(const SkPDFGlyphSet* usage); |
+ enum Match { |
+ kExact_Match, |
+ kRelated_Match, |
+ kNot_Match, |
+ }; |
+ static Match IsMatch(SkPDFFont* existingFont, |
+ uint32_t existingFontID, |
+ uint16_t existingGlyphID, |
+ uint32_t searchFontID, |
+ uint16_t searchGlyphID); |
+ |
protected: |
// Common constructor to handle common members. |
SkPDFFont(const SkAdvancedTypefaceMetrics* fontInfo, SkTypeface* typeface, |
@@ -178,17 +189,6 @@ protected: |
static bool Find(uint32_t fontID, uint16_t glyphID, int* index); |
private: |
- class FontRec { |
- public: |
- SkPDFFont* fFont; |
- uint32_t fFontID; |
- uint16_t fGlyphID; |
- |
- // A fGlyphID of 0 with no fFont always matches. |
- bool operator==(const FontRec& b) const; |
- FontRec(SkPDFFont* font, uint32_t fontID, uint16_t fGlyphID); |
- }; |
- |
SkAutoTUnref<SkTypeface> fTypeface; |
// The glyph IDs accessible with this font. For Type1 (non CID) fonts, |
@@ -201,10 +201,28 @@ private: |
SkAdvancedTypefaceMetrics::FontType fFontType; |
- // This should be made a hash table if performance is a problem. |
- static SkTDArray<FontRec>& CanonicalFonts(); |
- static SkBaseMutex& CanonicalFontsMutex(); |
typedef SkPDFDict INHERITED; |
}; |
+inline SkPDFFont::Match SkPDFFont::IsMatch(SkPDFFont* existingFont, |
mtklein
2015/01/20 21:59:51
This seems like an odd thing to implement inline h
hal.canary
2015/01/21 17:07:50
Done.
|
+ uint32_t existingFontID, |
+ uint16_t existingGlyphID, |
+ uint32_t searchFontID, |
+ uint16_t searchGlyphID) { |
+ if (existingFontID != searchFontID) { |
+ return SkPDFFont::kNot_Match; |
+ } |
+ if (existingGlyphID == 0 || searchGlyphID == 0) { |
+ return SkPDFFont::kExact_Match; |
+ } |
+ if (existingFont != NULL) { |
+ return (existingFont->fFirstGlyphID <= searchGlyphID && |
+ searchGlyphID <= existingFont->fLastGlyphID) |
+ ? SkPDFFont::kExact_Match |
+ : SkPDFFont::kRelated_Match; |
+ } |
+ return (existingGlyphID == searchGlyphID) ? SkPDFFont::kExact_Match |
+ : SkPDFFont::kRelated_Match; |
+} |
+ |
#endif |