[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1604-g30575d5

[email protected] (Till Kamppeter)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
       via  30575d50af5f8dd17ef20ccbbf2b2d8afae51589 (commit)
      from  3283e6d5ce389f5b6d5ebf4adb309b1259a5fe1d (commit)

----------------------------------------------------------------------
commit 30575d50af5f8dd17ef20ccbbf2b2d8afae51589
Author: Till Kamppeter <[email protected]>
Date:   Sun Aug 25 19:08:52 2019 +0200

    "cups"/"pwgraster" output device: Prefer the page size requested by user
    
    Without special scaling/cropping options ("fit-to-page", "fill",
    "crop-to-fit΅, ...) PDF and PostScript files printed with CUPS will be
    printed with the page sizes of the document's pages and not the size
    requested by the user via the "PageSize" or "media" option. This
    allows correct printing of jobs with differently sized pages on
    printers which have the appropriate sizes loaded without need of
    manual intervention. Therefore the CUPS output device is matching each
    input page against the sizes listed in the PPD to generate a correct
    page geometry for the printer for each page.
    
    Problem is if there are several equally-sized page size entries in the
    PPD. Without further guiding always the first match is used, making
    access to special functions provided by the others (like
    full-bleed/borderless printing) inaccessible.
    
    This commit adds the functionality of the user-requested page size
    (via "PageSize" or "media" option) being preferred under the matching
    page sizes, so that if for example a user selects a full-bleed version
    of the desired page size and sends a photo, the photo gets rendered
    and printed with the page geometry which the PPD reports for the
    full-bleed version.
    
    Nothing changes if the size of the user-requested page size does not
    match the size of the input page at all.

diff --git a/cups/gdevcups.c b/cups/gdevcups.c
index 54552b9..f6cd661 100644
--- a/cups/gdevcups.c
+++ b/cups/gdevcups.c
@@ -307,6 +307,7 @@ typedef struct gx_device_cups_s
   int			Matrix[3][3][CUPS_MAX_VALUE + 1];/* Color transform matrix LUT */
   int                   user_icc;
   int                   cupsRasterVersion;
+  char                  pageSizeRequested[64];
 
   /* Used by cups_put_params(): */
 } gx_device_cups;
@@ -516,7 +517,8 @@ private gx_device_procs	cups_procs =
    {{0x00},{0x00},{0x00}},\
    {{0x00},{0x00},{0x00}}},                /* Matrix */\
   0,                                       /* user_icc */\
-  3                                     /* cupsRasterVersion */
+  3,                                     /* cupsRasterVersion */\
+  ""                                     /* pageSizeRequested */
 
 gx_device_cups	gs_cups_device = { gs_xxx_device("cups", "") };
 gx_device_cups	gs_pwgraster_device = { gs_xxx_device("pwgraster",
@@ -2857,6 +2859,14 @@ cups_open(gx_device *pdev)		/* I - Device info */
   if (cups->PPD == NULL)
     cups->PPD = ppdOpenFile(getenv("PPD"));
 
+  if (cups->pageSizeRequested[0] == '\0') {
+    strncpy(cups->pageSizeRequested, cups->header.cupsPageSizeName, 64);
+#ifdef CUPS_DEBUG
+    dmprintf1(pdev->memory, "DEBUG: Page size requested: %s\n",
+	      cups->header.cupsPageSizeName);
+#endif /* CUPS_DEBUG */
+  }
+
   return (0);
 }
 
@@ -3107,7 +3117,8 @@ cups_put_params(gx_device     *pdev,	/* I - Device info */
   ppd_size_t            *best_size = NULL;
   int                   size_matched = 0,
                         margins_matched = 0,
-                        imageable_area_matched = 0;
+                        imageable_area_matched = 0,
+                        name_requested_matched = 0;
   float long_edge_mismatch, short_edge_mismatch;
   gs_param_string icc_pro_dummy;
   int old_cmps = cups->color_info.num_components;
@@ -3490,6 +3501,7 @@ cups_put_params(gx_device     *pdev,	/* I - Device info */
 	size_matched = 0;
 	margins_matched = 0;
 	imageable_area_matched = 0;
+	name_requested_matched = 0;
 
 	long_edge_mismatch =
 	  fabs(cups->MediaSize[1] - size->length)/size->length +
@@ -3565,6 +3577,13 @@ cups_put_params(gx_device     *pdev,	/* I - Device info */
 	else if (size_matched)
 	  score += PAGESIZE_SCORE_SIZE * 10000;
 
+	if (size_matched || imageable_area_matched) {
+	  if (!strcasecmp(cups->pageSizeRequested, size->name))
+	    name_requested_matched = 1;
+	  else
+	    score -= 1000;
+	}
+
 	if (score > best_score)
 	{
 	  best_score = score;
@@ -3581,8 +3600,9 @@ cups_put_params(gx_device     *pdev,	/* I - Device info */
 	dmprintf4(pdev->memory, "DEBUG2:    Size mismatch: Long Edge (%.3f): %.5f; Short Edge (%.3f): %.5f\n",
 		  LONG_EDGE_LENGTH_MATCH_LIMIT, long_edge_mismatch,
 		  SHORT_EDGE_LENGTH_MATCH_LIMIT, short_edge_mismatch);
-	dmprintf3(pdev->memory, "DEBUG2:    Match: Size: %d; Margins: %d; Imageable Area: %d\n",
-		  size_matched, margins_matched, imageable_area_matched);
+	dmprintf4(pdev->memory, "DEBUG2:    Match: Size: %d; Margins: %d; Imageable Area: %d; Name requested: %d\n",
+		  size_matched, margins_matched, imageable_area_matched,
+		  name_requested_matched);
 	dmprintf2(pdev->memory, "DEBUG2:    Score: %ld; Best Score: %ld\n",
 		  score, best_score);
 #endif /* CUPS_DEBUG */
@@ -3654,6 +3674,7 @@ cups_put_params(gx_device     *pdev,	/* I - Device info */
 	  size_matched = 0;
 	  margins_matched = 0;
 	  imageable_area_matched = 0;
+	  name_requested_matched = 0;
 
 	  long_edge_mismatch =
 	    fabs(cups->MediaSize[0] - size->length)/size->length +
@@ -3729,6 +3750,13 @@ cups_put_params(gx_device     *pdev,	/* I - Device info */
 	  else if (size_matched)
 	    score += PAGESIZE_SCORE_SIZE * 10000;
 
+	  if (size_matched || imageable_area_matched) {
+	    if (!strcasecmp(cups->pageSizeRequested, size->name))
+	      name_requested_matched = 1;
+	    else
+	      score -= 1000;
+	  }
+
 	  if (score > best_score)
 	  {
 	    best_score = score;
@@ -3745,8 +3773,9 @@ cups_put_params(gx_device     *pdev,	/* I - Device info */
 	  dmprintf4(pdev->memory, "DEBUG2:    Size mismatch: Long Edge (%.3f): %.5f; Short Edge (%.3f): %.5f\n",
 		    LONG_EDGE_LENGTH_MATCH_LIMIT, long_edge_mismatch,
 		    SHORT_EDGE_LENGTH_MATCH_LIMIT, short_edge_mismatch);
-	  dmprintf3(pdev->memory, "DEBUG2:    Match: Size: %d; Margins: %d; Imageable Area: %d\n",
-		    size_matched, margins_matched, imageable_area_matched);
+	  dmprintf4(pdev->memory, "DEBUG2:    Match: Size: %d; Margins: %d; Imageable Area: %d; Name requested: %d\n",
+		    size_matched, margins_matched, imageable_area_matched,
+		    name_requested_matched);
 	  dmprintf2(pdev->memory, "DEBUG2:    Score: %ld; Best Score: %ld\n",
 		    score, best_score);
 #endif /* CUPS_DEBUG */


Summary of changes:
 cups/gdevcups.c | 41 +++++++++++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 6 deletions(-)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.