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

Unified Diff: src/pdf/SkPDFDocument.cpp

Issue 334443002: [PDF] Fix font embedding restrictions. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 6 months 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
« no previous file with comments | « src/core/SkTypeface.cpp ('k') | src/pdf/SkPDFFont.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698