public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/libcupsfilters] rawhide: fix copying of indirect page resources in PDF (fixes printing test page)
@ 2026-11-11 16:18 Zdenek Dohnal
  0 siblings, 0 replies; only message in thread
From: Zdenek Dohnal @ 2026-11-11 16:18 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/libcupsfilters
Branch : rawhide
Commit : e5afb5bc6f578236e697ce6522aeaf3c74db8226
Author : Zdenek Dohnal <zdohnal@redhat.com>
Date   : 2026-11-11T17:18:29+01:00
Stats  : +114/-1 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/libcupsfilters/c/e5afb5bc6f578236e697ce6522aeaf3c74db8226?branch=rawhide

Log:
fix copying of indirect page resources in PDF (fixes printing test page)

---
diff --git a/0001-bannertopdf-preserve-indirect-page-resources-when-ad.patch b/0001-bannertopdf-preserve-indirect-page-resources-when-ad.patch
new file mode 100644
index 0000000..bd78d51
--- /dev/null
+++ b/0001-bannertopdf-preserve-indirect-page-resources-when-ad.patch
@@ -0,0 +1,108 @@
+From ce65eb7455b5dedb08943a6d966f12bc4eaf3caa Mon Sep 17 00:00:00 2001
+From: oubayashi <214973957@qq.com>
+Date: Thu, 24 Sep 2026 13:39:10 +0800
+Subject: [PATCH] bannertopdf: preserve indirect page resources when adding
+ fonts
+
+Resolve and copy an indirect page Resources dictionary before adding the
+banner font instead of replacing it with an empty dictionary.
+
+This preserves existing XObject, ExtGState, Font, and other resources from
+the banner template. Extend the Unicode banner regression test to verify
+that the template image resources and drawing commands remain present.
+---
+ cupsfilters/pdf.c                      | 22 ++++++++++++++++++----
+ cupsfilters/test-bannertopdf-unicode.c | 20 +++++++++++++++++++-
+ 2 files changed, 37 insertions(+), 5 deletions(-)
+
+diff --git a/cupsfilters/pdf.c b/cupsfilters/pdf.c
+index 252f85b8..2645a593 100644
+--- a/cupsfilters/pdf.c
++++ b/cupsfilters/pdf.c
+@@ -370,15 +370,30 @@ cfPDFAddType1Font1(cf_pdf_t *pdf, 	// I - Pointer to PDF object
+ {
+   pdfio_dict_t *fonts;
+   pdfio_dict_t *pageDict = iterate_helper->page_dict;
++  pdfio_valtype_t resources_type;
+   if (!pageDict) 
+     return 1; 
+ 
+   // Locate or create the Resources dictionary
+-  pdfio_dict_t *resources = pdfioDictGetDict(pageDict, "Resources");
+-  if (!resources) 
++  pdfio_dict_t *resources;
++  resources_type = pdfioDictGetType(pageDict, "Resources");
++  if (resources_type == PDFIO_VALTYPE_INDIRECT)
++  {
++    pdfio_obj_t *resources_obj = pdfioDictGetObj(pageDict, "Resources");
++
++    if (!resources_obj ||
++	(resources = pdfioDictCopy((pdfio_file_t *)iterate_helper->pdf,
++				   pdfioObjGetDict(resources_obj))) == NULL ||
++	!pdfioDictSetDict(pageDict, "Resources", resources))
++      return 1;
++  }
++  else if (resources_type == PDFIO_VALTYPE_DICT)
++    resources = pdfioDictGetDict(pageDict, "Resources");
++  else
+   {
+     resources = pdfioDictCreate((pdfio_file_t *)iterate_helper->pdf);
+-    pdfioDictSetDict(pageDict, "Resources", resources);
++    if (!resources || !pdfioDictSetDict(pageDict, "Resources", resources))
++      return 1;
+   }
+ 
+   // Locate or create the Font dictionary within Resources
+@@ -615,4 +630,3 @@ cfPDFFillForm(cf_pdf_t *doc,    // I - PDF document
+   // TODO: PDFio does not directly support form filling.
+   return 1;
+ }
+-
+diff --git a/cupsfilters/test-bannertopdf-unicode.c b/cupsfilters/test-bannertopdf-unicode.c
+index 9e40dfc6..a9877f9d 100644
+--- a/cupsfilters/test-bannertopdf-unicode.c
++++ b/cupsfilters/test-bannertopdf-unicode.c
+@@ -106,7 +106,7 @@ main(int argc, char *argv[])
+ {
+   pdfio_file_t *pdf;
+   pdfio_obj_t *page;
+-  pdfio_dict_t *resources, *fonts, *unicode_font;
++  pdfio_dict_t *resources, *fonts, *unicode_font, *xobjects;
+   char *contents;
+   int status = 1;
+ 
+@@ -137,6 +137,15 @@ main(int argc, char *argv[])
+     goto done;
+   }
+ 
++  if ((xobjects = get_dict(resources, "XObject")) == NULL ||
++      pdfioDictGetObj(xobjects, "x6") == NULL ||
++      pdfioDictGetObj(xobjects, "x7") == NULL ||
++      pdfioDictGetObj(xobjects, "x8") == NULL)
++  {
++    fputs("Template image resources were not preserved.\n", stderr);
++    goto done;
++  }
++
+   if (get_dict(fonts, "bannertopdf-font") == NULL)
+   {
+     fputs("Courier banner font resource is missing.\n", stderr);
+@@ -182,6 +191,15 @@ main(int argc, char *argv[])
+     goto done;
+   }
+ 
++  if (!strstr(contents, "/x6 Do") ||
++      !strstr(contents, "/x7 Do") ||
++      !strstr(contents, "/x8 Do"))
++  {
++    fputs("Template image drawing commands were not preserved.\n", stderr);
++    free(contents);
++    goto done;
++  }
++
+   if (!strstr(contents, "Office \\(Floor 2\\) \\\\ Queue"))
+   {
+     fputs("ASCII PDF literal string escaping is incorrect.\n", stderr);
+-- 
+2.56.0
+

diff --git a/libcupsfilters.spec b/libcupsfilters.spec
index 32e74f1..78fa35d 100644
--- a/libcupsfilters.spec
+++ b/libcupsfilters.spec
@@ -7,7 +7,7 @@
 Name: libcupsfilters
 Epoch: 1
 Version: 2.2.1
-Release: 7%{?dist}
+Release: 8%{?dist}
 Summary: Library for developing printing filters
 # the CUPS exception text is the same as LLVM exception, so using that name with
 # agreement from legal team
@@ -35,6 +35,8 @@ Patch007: 0001-ghostscript-serialize-raster-integer-parameters-as-s.patch
 Patch008: 0001-pdftopdf-keep-annotations-without-an-appearance-from.patch
 # https://github.com/OpenPrinting/libcupsfilters/commit/b13e63e80d9c094bc4484dcbc7efd000f21308db
 Patch009: 0001-libcupsfilters.pc-Add-pdfio-as-public-Requires-dep.patch
+# https://github.com/OpenPrinting/libcupsfilters/commit/ce65eb7455b5
+Patch010: 0001-bannertopdf-preserve-indirect-page-resources-when-ad.patch
 
 
 # for generating configure and Makefile scripts in autogen.h
@@ -220,6 +222,9 @@ rm -f %{buildroot}%{_pkgdocdir}/{LICENSE,COPYING,NOTICE}
 
 
 %changelog
+* Wed Nov 11 2026 Zdenek Dohnal <zdohnal@redhat.com> - 1:2.2.1-8
+- fix copying of indirect page resources in PDF (fixes printing test page)
+
 * Mon Nov 09 2026 Yaakov Selkowitz <yselkowi@redhat.com> - 1:2.2.1-7
 - libcupsfilters-devel requires pdfio-devel
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-11 16:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 16:18 [rpms/libcupsfilters] rawhide: fix copying of indirect page resources in PDF (fixes printing test page) Zdenek Dohnal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox