Package: cups
Version: 2.4.10-3+deb13u2
Severity: normal
Tags: patch upstream

Dear Maintainer,

With a Foomatic PPD whose ColorModel option names the gray choice
"Grayscale" (for example foomatic:Brother-HL-4050CDN-pxlcolor.ppd, or the
color Ricoh/Lanier/Savin/Gestetner/NRG/Infotec PPDs in foomatic-db), CUPS
advertises print-color-mode-supported = monochrome,color but never applies
monochrome. The black and white toggle on iOS and macOS appears and has no
effect: every job prints in color.

Steps to reproduce:

 lpadmin -p test -E -v socket://PRINTER:9100 \
         -m foomatic:Brother-HL-4050CDN-pxlcolor.ppd
 cupsctl LogLevel=debug2
 lp -d test -o print-color-mode=monochrome file.pdf

The error_log has no "Adding preset option" line and foomatic-rip runs
Ghostscript with -sDEVICE=pxlcolor. "lp -o ColorModel=Grayscale" on the same
queue prints in grayscale, so the driver itself works.

Cause: when a PPD has no *APPrinterPreset, _ppdCacheCreateWithPPD() in
cups/ppd-cache.c creates grayscale presets only for a fixed list of
option/choice pairs, and ColorModel=Grayscale is not in it. Ubuntu does not
show the problem because it carries 9100-ppd-cache-add-auto-presets.patch;
that larger change was not merged upstream (OpenPrinting/cups PR #236).

A minimal fix adding ColorModel=Grayscale to the list has been submitted
upstream. The same patch applies cleanly to the 2.4.x branch:

 Issue: https://github.com/OpenPrinting/cups/issues/1815
 Pull request: https://github.com/OpenPrinting/cups/pull/1816

--- a/cups/ppd-cache.c
+++ b/cups/ppd-cache.c
@@ -1634,6 +1634,12 @@ _ppdCacheCreateWithPPD(
      color_option = "ColorModel";
      gray_choice  = "Gray";
    }
+    else if ((color_model = ppdFindOption(ppd, "ColorModel")) != NULL &&
+             ppdFindChoice(color_model, "Grayscale"))
+    {
+      color_option = "ColorModel";
+      gray_choice  = "Grayscale";
+    }
    else if ((color_model = ppdFindOption(ppd, "HPColorMode")) != NULL &&
             ppdFindChoice(color_model, "grayscale"))
    {

For a Debian backport the cache version (_PPD_CACHE_VERSION in
cups/ppd-private.h) would need a bump, so existing queues pick up the new
preset without the PPD being reinstalled.

Workaround until then: add *APPrinterPreset entries to the queue's PPD and
reinstall it with lpadmin -P.

AI disclosure: this report and the patch were prepared with the help of AI
(Claude, by Anthropic). The bug was reproduced on my own setup, and the
patch was compiled and tested against upstream master.

-- System Information:
Debian Release: 13 (trixie), in a Docker container (debian:trixie-slim)
Architecture: arm64
Versions: cups 2.4.10-3+deb13u2, cups-filters 1.28.17-6+deb13u1,
         ghostscript 10.05.1~dfsg-1+deb13u3

Rogério de Camargo Rocha

Reply via email to