aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/pdf/SkPDFDevice.h4
-rw-r--r--include/pdf/SkPDFFont.h6
-rw-r--r--include/pdf/SkPDFPage.h4
-rw-r--r--src/pdf/SkPDFDevice.cpp4
-rwxr-xr-xsrc/pdf/SkPDFFont.cpp32
-rw-r--r--src/pdf/SkPDFPage.cpp4
6 files changed, 37 insertions, 17 deletions
diff --git a/include/pdf/SkPDFDevice.h b/include/pdf/SkPDFDevice.h
index 2a9aba5984..5e050211be 100644
--- a/include/pdf/SkPDFDevice.h
+++ b/include/pdf/SkPDFDevice.h
@@ -127,6 +127,10 @@ public:
*/
void getResources(SkTDArray<SkPDFObject*>* resourceList) const;
+ /** Get the fonts used on this device.
+ */
+ const SkTDArray<SkPDFFont*>& getFontResources() const;
+
/** Returns the media box for this device.
*/
SkRefPtr<SkPDFArray> getMediaBox() const;
diff --git a/include/pdf/SkPDFFont.h b/include/pdf/SkPDFFont.h
index 45e4195345..9ba32e330c 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<SkTypeface> fTypeface;
+ SkAdvancedTypefaceMetrics::FontType fType;
#ifdef SK_DEBUG
bool fDescendant;
#endif
diff --git a/include/pdf/SkPDFPage.h b/include/pdf/SkPDFPage.h
index b12be16fa2..d677a29182 100644
--- a/include/pdf/SkPDFPage.h
+++ b/include/pdf/SkPDFPage.h
@@ -86,6 +86,10 @@ public:
SkTDArray<SkPDFDict*>* pageTree,
SkPDFDict** rootNode);
+ /** Get the fonts used on this page.
+ */
+ const SkTDArray<SkPDFFont*>& getFontResources() const;
+
private:
// Multiple pages may reference the content.
SkRefPtr<SkPDFDevice> fDevice;
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 4c0021a666..c6ddf39966 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -1051,6 +1051,10 @@ void SkPDFDevice::getResources(SkTDArray<SkPDFObject*>* resourceList) const {
}
}
+const SkTDArray<SkPDFFont*>& SkPDFDevice::getFontResources() const {
+ return fFontResources;
+}
+
SkRefPtr<SkPDFArray> SkPDFDevice::getMediaBox() const {
SkRefPtr<SkPDFInt> 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 cc249ca9d3..277ed12ac3 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 9aa21c69f7..2a8183d425 100644
--- a/src/pdf/SkPDFPage.cpp
+++ b/src/pdf/SkPDFPage.cpp
@@ -136,3 +136,7 @@ void SkPDFPage::generatePageTree(const SkTDArray<SkPDFPage*>& pages,
if (rootNode)
*rootNode = curNodes[0];
}
+
+const SkTDArray<SkPDFFont*>& SkPDFPage::getFontResources() const {
+ return fDevice->getFontResources();
+}