public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Zdenek Dohnal <zdohnal@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/libcupsfilters] rawhide: fix copying of indirect page resources in PDF (fixes printing test page)
Date: Wed, 11 Nov 2026 16:18:37 GMT	[thread overview]
Message-ID: <179441391786.1.3136839934527400443.rpms-libcupsfilters-e5afb5bc6f57@fedoraproject.org> (raw)

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
 

                 reply	other threads:[~2026-11-11 16:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179441391786.1.3136839934527400443.rpms-libcupsfilters-e5afb5bc6f57@fedoraproject.org \
    --to=zdohnal@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox