Polish CPDF_FontSubsetter and its embedder tests Polish CPDF_FontSubsetter and its embedder tests one more time by performing the following: 1. Add comments mentioning that Type 1 font subsetting is not supported, and the reason why. 2. Fix PrintTo() not being used. https://pdfium-review.googlesource.com/c/pdfium/+/143773 modified the obj param type, but this caused gtest to not be able to look up the function. The obj type must be a const-ref. Fixed: 476127152 Change-Id: Ia620844b20d55dbccd749b4b2e9049b33ea8bf94 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/143990 Commit-Queue: Andy Phan <andyphan@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/edit/cpdf_fontsubsetter.cpp b/core/fpdfapi/edit/cpdf_fontsubsetter.cpp index 381ce29..490d401 100644 --- a/core/fpdfapi/edit/cpdf_fontsubsetter.cpp +++ b/core/fpdfapi/edit/cpdf_fontsubsetter.cpp
@@ -280,6 +280,9 @@ continue; } + // Internally, all embedded font file streams are set as "FontFile" or + // "FontFile2". HarfBuzz does not support subsetting Type 1 fonts, so fonts + // with "FontFile" are ignored. RetainPtr<const CPDF_Stream> font_stream = descriptor->GetStreamFor("FontFile2"); if (!font_stream) {
diff --git a/core/fpdfapi/edit/cpdf_fontsubsetter.h b/core/fpdfapi/edit/cpdf_fontsubsetter.h index 954301b..be5633a 100644 --- a/core/fpdfapi/edit/cpdf_fontsubsetter.h +++ b/core/fpdfapi/edit/cpdf_fontsubsetter.h
@@ -26,6 +26,7 @@ // in order to subset new embedded fonts. CPDF_FontSubsetter only creates new // PDF objects and does not modify any existing PDF objects. Use during saving // to create objects that should override existing objects when writing the PDF. +// CPDF_FontSubsetter does not support Type 1 fonts. class CPDF_FontSubsetter { public: explicit CPDF_FontSubsetter(CPDF_Document* doc);
diff --git a/core/fpdfapi/edit/cpdf_fontsubsetter_embeddertest.cpp b/core/fpdfapi/edit/cpdf_fontsubsetter_embeddertest.cpp index 93d6edd..500ca02 100644 --- a/core/fpdfapi/edit/cpdf_fontsubsetter_embeddertest.cpp +++ b/core/fpdfapi/edit/cpdf_fontsubsetter_embeddertest.cpp
@@ -276,7 +276,7 @@ } // namespace // Prints overrides nicely for debugging purposes. -void PrintTo(const CPDF_Object* obj, std::ostream* os) { +void PrintTo(const RetainPtr<const CPDF_Object>& obj, std::ostream* os) { if (!obj) { *os << "nullptr"; return;