aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-29 05:55:42 +0000
committerGravatar vandebo@chromium.org <vandebo@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-29 05:55:42 +0000
commitf0ec2666d9a3f0f1662f0d63b5147628c49648aa (patch)
treeae2bebb2182bfad6d4b0348b76481f16ecedcec6 /src
parentd7beab42527fb03e3b86b9016665fd9aebc74265 (diff)
[PDF] Add plumbing and accessors so that Chrome can record the font types used in a PDF.
- Add a font type accessor to SkPDFFont. - Plumb font resource retrivial up to SkPDFPage. Review URL: http://codereview.appspot.com/4547069 git-svn-id: http://skia.googlecode.com/svn/trunk@1444 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/pdf/SkPDFDevice.cpp4
-rwxr-xr-xsrc/pdf/SkPDFFont.cpp32
-rw-r--r--src/pdf/SkPDFPage.cpp4
3 files changed, 23 insertions, 17 deletions
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();
+}