diff --git a/include/pdf/SkPDFDevice.h b/include/pdf/SkPDFDevice.h index 2a9aba598..5e050211b 100644 --- a/include/pdf/SkPDFDevice.h +++ b/include/pdf/SkPDFDevice.h @@ -127,6 +127,10 @@ public: */ void getResources(SkTDArray* resourceList) const; + /** Get the fonts used on this device. + */ + const SkTDArray& getFontResources() const; + /** Returns the media box for this device. */ SkRefPtr getMediaBox() const; diff --git a/include/pdf/SkPDFFont.h b/include/pdf/SkPDFFont.h index 45e419534..9ba32e330 100644 --- a/include/pdf/SkPDFFont.h +++ b/include/pdf/SkPDFFont.h @@ -42,6 +42,11 @@ public: */ SkTypeface* typeface(); + /** Returns the font type represented in this font. For Type0 fonts, + * returns the type of the decendant font. + */ + SkAdvancedTypefaceMetrics::FontType getType(); + /** Return true if this font has an encoding for the passed glyph id. */ bool hasGlyph(uint16_t glyphID); @@ -72,6 +77,7 @@ public: private: SkRefPtr fTypeface; + SkAdvancedTypefaceMetrics::FontType fType; #ifdef SK_DEBUG bool fDescendant; #endif diff --git a/include/pdf/SkPDFPage.h b/include/pdf/SkPDFPage.h index b12be16fa..d677a2918 100644 --- a/include/pdf/SkPDFPage.h +++ b/include/pdf/SkPDFPage.h @@ -86,6 +86,10 @@ public: SkTDArray* pageTree, SkPDFDict** rootNode); + /** Get the fonts used on this page. + */ + const SkTDArray& getFontResources() const; + private: // Multiple pages may reference the content. SkRefPtr fDevice; diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 4c0021a66..c6ddf3996 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -1051,6 +1051,10 @@ void SkPDFDevice::getResources(SkTDArray* resourceList) const { } } +const SkTDArray& SkPDFDevice::getFontResources() const { + return fFontResources; +} + SkRefPtr SkPDFDevice::getMediaBox() const { SkRefPtr zero = new SkPDFInt(0); zero->unref(); // SkRefPtr and new both took a reference. diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp index cc249ca9d..277ed12ac 100755 --- a/src/pdf/SkPDFFont.cpp +++ b/src/pdf/SkPDFFont.cpp @@ -444,6 +444,10 @@ SkTypeface* SkPDFFont::typeface() { return fTypeface.get(); } +SkAdvancedTypefaceMetrics::FontType SkPDFFont::getType() { + return fType; +} + bool SkPDFFont::hasGlyph(uint16_t id) { return (id >= fFirstGlyphID && id <= fLastGlyphID) || id == 0; } @@ -541,6 +545,8 @@ SkPDFFont::SkPDFFont(class SkAdvancedTypefaceMetrics* fontInfo, SkPDFDict* fontDescriptor) : SkPDFDict("Font"), fTypeface(typeface), + fType(fontInfo ? fontInfo->fType : + SkAdvancedTypefaceMetrics::kNotEmbeddable_Font), #ifdef SK_DEBUG fDescendant(descendantFont), #endif @@ -549,20 +555,12 @@ SkPDFFont::SkPDFFont(class SkAdvancedTypefaceMetrics* fontInfo, fLastGlyphID(fontInfo ? fontInfo->fLastGlyphID : 0), fFontInfo(fontInfo), fDescriptor(fontDescriptor) { - - SkAdvancedTypefaceMetrics::FontType type; - if (fontInfo) { - type = fontInfo->fType; - } else { - type = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font; - } - if (fontInfo && fontInfo->fMultiMaster) { - SkASSERT(false); // Not supported yet. - fontInfo->fType = SkAdvancedTypefaceMetrics::kOther_Font; + NOT_IMPLEMENTED(true, true); + fType = SkAdvancedTypefaceMetrics::kOther_Font; } - if (type == SkAdvancedTypefaceMetrics::kType1CID_Font || - type == SkAdvancedTypefaceMetrics::kTrueType_Font) { + if (fType == SkAdvancedTypefaceMetrics::kType1CID_Font || + fType == SkAdvancedTypefaceMetrics::kTrueType_Font) { if (descendantFont) { populateCIDFont(); } else { @@ -574,15 +572,15 @@ SkPDFFont::SkPDFFont(class SkAdvancedTypefaceMetrics* fontInfo, return; } - if (type == SkAdvancedTypefaceMetrics::kType1_Font && + if (fType == SkAdvancedTypefaceMetrics::kType1_Font && populateType1Font(glyphID)) { return; } - SkASSERT(type == SkAdvancedTypefaceMetrics::kType1_Font || - type == SkAdvancedTypefaceMetrics::kCFF_Font || - type == SkAdvancedTypefaceMetrics::kOther_Font || - type == SkAdvancedTypefaceMetrics::kNotEmbeddable_Font); + SkASSERT(fType == SkAdvancedTypefaceMetrics::kType1_Font || + fType == SkAdvancedTypefaceMetrics::kCFF_Font || + fType == SkAdvancedTypefaceMetrics::kOther_Font || + fType == SkAdvancedTypefaceMetrics::kNotEmbeddable_Font); populateType3Font(glyphID); } diff --git a/src/pdf/SkPDFPage.cpp b/src/pdf/SkPDFPage.cpp index 9aa21c69f..2a8183d42 100644 --- a/src/pdf/SkPDFPage.cpp +++ b/src/pdf/SkPDFPage.cpp @@ -136,3 +136,7 @@ void SkPDFPage::generatePageTree(const SkTDArray& pages, if (rootNode) *rootNode = curNodes[0]; } + +const SkTDArray& SkPDFPage::getFontResources() const { + return fDevice->getFontResources(); +}