Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1102)

Unified Diff: src/pdf/SkPDFDocument.cpp

Issue 107863002: [PDF] Fix font embedding restrictions. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix Mac Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/pdf/SkPDFDocument.cpp
diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp
index 0633d308285d116ef121e5bd754927639aaf2337..79699a0292f13c8290bb82fdcbd166c2e6e7d985 100644
--- a/src/pdf/SkPDFDocument.cpp
+++ b/src/pdf/SkPDFDocument.cpp
@@ -258,11 +258,13 @@ bool SkPDFDocument::appendPage(SkPDFDevice* pdfDevice) {
return true;
}
+// Deprecated.
void SkPDFDocument::getCountOfFontTypes(
- int counts[SkAdvancedTypefaceMetrics::kNotEmbeddable_Font + 1]) const {
+ int counts[SkAdvancedTypefaceMetrics::kOther_Font + 2]) const {
sk_bzero(counts, sizeof(int) *
- (SkAdvancedTypefaceMetrics::kNotEmbeddable_Font + 1));
+ (SkAdvancedTypefaceMetrics::kOther_Font + 2));
SkTDArray<SkFontID> seenFonts;
+ int notEmbeddable = 0;
for (int pageNumber = 0; pageNumber < fPages.count(); pageNumber++) {
const SkTDArray<SkPDFFont*>& fontResources =
@@ -272,9 +274,49 @@ void SkPDFDocument::getCountOfFontTypes(
if (seenFonts.find(fontID) == -1) {
counts[fontResources[font]->getType()]++;
seenFonts.push(fontID);
+ if (!fontResources[font]->canEmbed()) {
+ notEmbeddable++;
+ }
}
}
}
+ counts[SkAdvancedTypefaceMetrics::kOther_Font + 1] = notEmbeddable;
+}
+
+void SkPDFDocument::getCountOfFontTypes(
+ int counts[SkAdvancedTypefaceMetrics::kOther_Font + 1],
+ int* notSubsettableCount,
+ int* notEmbeddableCount) const {
+ sk_bzero(counts, sizeof(int) *
+ (SkAdvancedTypefaceMetrics::kOther_Font + 1));
+ SkTDArray<SkFontID> seenFonts;
+ int notSubsettable = 0;
+ int notEmbeddable = 0;
+
+ for (int pageNumber = 0; pageNumber < fPages.count(); pageNumber++) {
+ const SkTDArray<SkPDFFont*>& fontResources =
+ fPages[pageNumber]->getFontResources();
+ for (int font = 0; font < fontResources.count(); font++) {
+ SkFontID fontID = fontResources[font]->typeface()->uniqueID();
+ if (seenFonts.find(fontID) == -1) {
+ counts[fontResources[font]->getType()]++;
+ seenFonts.push(fontID);
+ if (!fontResources[font]->canSubset()) {
+ notSubsettable++;
+ }
+ if (!fontResources[font]->canEmbed()) {
+ notEmbeddable++;
+ }
+ }
+ }
+ }
+ if (notSubsettableCount) {
+ *notSubsettableCount = notSubsettable;
+
+ }
+ if (notEmbeddableCount) {
+ *notEmbeddableCount = notEmbeddable;
+ }
}
void SkPDFDocument::emitHeader(SkWStream* stream) {
« no previous file with comments | « src/core/SkTypeface.cpp ('k') | src/pdf/SkPDFFont.h » ('j') | src/ports/SkFontHost_win.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698