Skip to content

Commit

Permalink
PPD file generator: Set default color mode when printer attrs say "auto"
Browse files Browse the repository at this point in the history
With the printer reporting "print-color-mode-default=auto" in its IPP
attributes "RGB" got never set as default when for the ColorModel
option when a color choice got found for "print-color-mode", but
"Gray" was set when there was a standard monochromr choice, leadin to
color printers getting grayscale as default color mode.

Now this is fixed and always the "best" color mode chosen as default.

See https://bugs.launchpad.net/bugs/2014976
  • Loading branch information
tillkamppeter committed Apr 2, 2023
1 parent 6ea77e9 commit 1934a6c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ppd/ppd-generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer
if (attr && ippGetCount(attr) > 0)
{
const char *default_color = NULL; // Default
int default_color_set = 0;
int first_choice = 1;

if ((keyword = ippGetString(defattr, 0, NULL)) != NULL &&
Expand All @@ -1387,6 +1388,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer
default_color = "ProcessGray";
else
default_color = "RGB";
default_color_set = 1;
}

cupsFilePrintf(fp, "*%% ColorModel from %s\n", ippGetName(attr));
Expand All @@ -1411,7 +1413,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer
cupsFilePrintf(fp, "*ColorModel FastGray/%s: \"\"\n",
(human_readable2 ? human_readable2 : "Text"));

if (!default_color)
if (!default_color_set && !default_color)
default_color = "FastGray";
}
else if (!strcmp(keyword, "process-bi-level"))
Expand Down Expand Up @@ -1465,7 +1467,8 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer
cupsFilePrintf(fp, "*ColorModel Gray/%s: \"\"\n",
(human_readable2 ? human_readable2 : "Monochrome"));

if (!default_color || (!defattr && !strcmp(default_color, "FastGray")))
if (!default_color_set &&
(!default_color || !strcmp(default_color, "FastGray")))
default_color = "Gray";
}
else if (!strcmp(keyword, "process-monochrome"))
Expand Down Expand Up @@ -1502,7 +1505,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer
cupsFilePrintf(fp, "*ColorModel RGB/%s: \"\"\n",
(human_readable2 ? human_readable2 : "Color"));

if (!defattr)
if (!default_color_set)
default_color = "RGB";

// Apparently some printers only advertise color support, so make sure
Expand Down

0 comments on commit 1934a6c

Please sign in to comment.