diff --git a/ghostscript-gdevcups-y-axis.patch b/ghostscript-gdevcups-y-axis.patch new file mode 100644 index 0000000..6e92ca1 --- /dev/null +++ b/ghostscript-gdevcups-y-axis.patch @@ -0,0 +1,698 @@ +diff -up ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis ghostscript-8.70/cups/gdevcups.c +--- ghostscript-8.70/cups/gdevcups.c.gdevcups-y-axis 2010-01-21 11:17:55.974149011 +0000 ++++ ghostscript-8.70/cups/gdevcups.c 2010-01-21 11:18:54.823149257 +0000 +@@ -605,8 +605,6 @@ private void + cups_get_matrix(gx_device *pdev, /* I - Device info */ + gs_matrix *pmat) /* O - Physical transform matrix */ + { +- ppd_attr_t *backside = NULL; +- + dprintf2("DEBUG2: cups_get_matrix(%p, %p)\n", pdev, pmat); + + /* +@@ -620,119 +618,25 @@ cups_get_matrix(gx_device *pdev, /* I - + * Set the transform matrix... + */ + +- dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); +- dprintf1("DEBUG2: cups->page = %d\n", cups->page); +- +- if (cupsPPD) +- { +- backside = ppdFindAttr(cupsPPD, "cupsBackSide", NULL); +- dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); +- if (backside) { +- dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value); +- cupsPPD->flip_duplex = 0; +- } +- dprintf1("DEBUG2: cupsPPD->flip_duplex = %d\n", cupsPPD->flip_duplex); +- } +- + if (cups->landscape) + { + /* + * Do landscape orientation... + */ +- +- if (cups->header.Duplex && cupsPPD && +- (cups->header.Tumble && +- (backside && !strcasecmp(backside->value, "Flipped"))) && +- !(cups->page & 1)) +- { +- pmat->xx = 0.0; +- pmat->xy = (float)cups->header.HWResolution[1] / 72.0; +- pmat->yx = (float)cups->header.HWResolution[0] / 72.0; +- pmat->yy = 0.0; +- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; +- pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[0] / 72.0; +- } +- else if (cups->header.Duplex && cupsPPD && +- (!cups->header.Tumble && +- (backside && !strcasecmp(backside->value, "Flipped"))) && +- !(cups->page & 1)) +- { +- pmat->xx = 0.0; +- pmat->xy = -(float)cups->header.HWResolution[1] / 72.0; +- pmat->yx = (float)cups->header.HWResolution[0] / 72.0; +- pmat->yy = 0.0; +- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; +- pmat->ty = (float)cups->header.HWResolution[1] * +- ((float)cups->header.PageSize[0] - pdev->HWMargins[2]) / 72.0; +- } +- else if (cups->header.Duplex && cupsPPD && +- ((!cups->header.Tumble && +- (cupsPPD->flip_duplex || +- (backside && !strcasecmp(backside->value, "Rotated")))) || +- (cups->header.Tumble && +- (backside && !strcasecmp(backside->value, "ManualTumble")))) && +- !(cups->page & 1)) +- { +- pmat->xx = 0.0; +- pmat->xy = -(float)cups->header.HWResolution[1] / 72.0; +- pmat->yx = (float)cups->header.HWResolution[0] / 72.0; +- pmat->yy = 0.0; +- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; +- pmat->ty = (float)cups->header.HWResolution[1] * +- ((float)cups->header.PageSize[0] - pdev->HWMargins[2]) / 72.0; +- } +- else +- { +- pmat->xx = 0.0; +- pmat->xy = (float)cups->header.HWResolution[1] / 72.0; +- pmat->yx = (float)cups->header.HWResolution[0] / 72.0; +- pmat->yy = 0.0; +- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; +- pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[0] / 72.0; +- } +- } +- else if (cups->header.Duplex && cupsPPD && +- (cups->header.Tumble && +- (backside && !strcasecmp(backside->value, "Flipped"))) && +- !(cups->page & 1)) +- { +- pmat->xx = (float)cups->header.HWResolution[0] / 72.0; +- pmat->xy = 0.0; +- pmat->yx = 0.0; +- pmat->yy = -(float)cups->header.HWResolution[1] / 72.0; +- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[0] / 72.0; +- pmat->ty = (float)cups->header.HWResolution[1] * +- ((float)cups->header.PageSize[1] - pdev->HWMargins[3]) / 72.0; +- } +- else if (cups->header.Duplex && cupsPPD && +- (!cups->header.Tumble && +- (backside && !strcasecmp(backside->value, "Flipped"))) && +- !(cups->page & 1)) +- { +- pmat->xx = (float)cups->header.HWResolution[0] / 72.0; +- pmat->xy = 0.0; +- pmat->yx = 0.0; +- pmat->yy = (float)cups->header.HWResolution[1] / 72.0; +- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[0] / 72.0; +- pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[1] / 72.0; +- } +- else if (cups->header.Duplex && cupsPPD && +- ((!cups->header.Tumble && +- (cupsPPD->flip_duplex || +- (backside && !strcasecmp(backside->value, "Rotated")))) || +- (cups->header.Tumble && +- (backside && !strcasecmp(backside->value, "ManualTumble")))) && +- !(cups->page & 1)) +- { +- pmat->xx = (float)cups->header.HWResolution[0] / 72.0; +- pmat->xy = 0.0; +- pmat->yx = 0.0; +- pmat->yy = (float)cups->header.HWResolution[1] / 72.0; +- pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[0] / 72.0; +- pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[1] / 72.0; ++ dprintf("DEBUG2: Landscape matrix: XX=0 XY=+1 YX=+1 YY=0\n"); ++ pmat->xx = 0.0; ++ pmat->xy = (float)cups->header.HWResolution[1] / 72.0; ++ pmat->yx = (float)cups->header.HWResolution[0] / 72.0; ++ pmat->yy = 0.0; ++ pmat->tx = -(float)cups->header.HWResolution[0] * pdev->HWMargins[1] / 72.0; ++ pmat->ty = -(float)cups->header.HWResolution[1] * pdev->HWMargins[0] / 72.0; + } + else + { ++ /* ++ * Do portrait orientation... ++ */ ++ dprintf("DEBUG2: Portrait matrix: XX=+1 XY=0 YX=0 YY=-1\n"); + pmat->xx = (float)cups->header.HWResolution[0] / 72.0; + pmat->xy = 0.0; + pmat->yx = 0.0; +@@ -2799,6 +2703,7 @@ cups_put_params(gx_device *pdev, /* + int xflip = 0, + yflip = 0; + int found = 0; ++ static int lastpage = 0; + + dprintf2("DEBUG2: cups_put_params(%p, %p)\n", pdev, plist); + +@@ -2895,6 +2800,15 @@ cups_put_params(gx_device *pdev, /* + size_set = param_read_float_array(plist, ".MediaSize", &arrayval) == 0 || + param_read_float_array(plist, "PageSize", &arrayval) == 0; + margins_set = param_read_float_array(plist, "Margins", &arrayval) == 0; ++ /* We also recompute page size and margins if we simply get onto a new ++ page without necessarily having a page size change in the PostScript ++ code, as for some printers margins have to flipped on the back sides of ++ the sheets (even pages) when printing duplex */ ++ if (cups->page != lastpage) { ++ size_set = 1; ++ margins_set = 1; ++ lastpage = cups->page; ++ } + color_set = param_read_int(plist, "cupsColorSpace", &intval) == 0 || + param_read_int(plist, "cupsBitsPerColor", &intval) == 0; + +@@ -2995,7 +2909,7 @@ cups_put_params(gx_device *pdev, /* + * Update margins/sizes as needed... + */ + +- if (size_set) ++ if (size_set || margins_set) + { + /* + * Compute the page margins... +@@ -3011,6 +2925,7 @@ cups_put_params(gx_device *pdev, /* + if (cupsPPD != NULL) + { + dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); ++ dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble); + dprintf1("DEBUG2: cups->page = %d\n", cups->page); + dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); + +@@ -3034,10 +2949,13 @@ cups_put_params(gx_device *pdev, /* + { + xflip = 1; + if (backsiderequiresflippedmargins && +- !strcasecmp(backsiderequiresflippedmargins->value, "False")) ++ !strcasecmp(backsiderequiresflippedmargins->value, "False")) { ++ dprintf("DEBUG2: (1) Flip: X=1 Y=0\n"); + yflip = 0; +- else ++ } else { ++ dprintf("DEBUG2: (1) Flip: X=1 Y=1\n"); + yflip = 1; ++ } + } + else if (cups->header.Duplex && + (!cups->header.Tumble && +@@ -3046,10 +2964,13 @@ cups_put_params(gx_device *pdev, /* + { + xflip = 0; + if (backsiderequiresflippedmargins && +- !strcasecmp(backsiderequiresflippedmargins->value, "False")) ++ !strcasecmp(backsiderequiresflippedmargins->value, "False")) { ++ dprintf("DEBUG2: (2) Flip: X=0 Y=1\n"); + yflip = 1; +- else ++ } else { ++ dprintf("DEBUG2: (2) Flip: X=0 Y=0\n"); + yflip = 0; ++ } + } + else if (cups->header.Duplex && + ((!cups->header.Tumble && +@@ -3061,13 +2982,17 @@ cups_put_params(gx_device *pdev, /* + { + xflip = 1; + if (backsiderequiresflippedmargins && +- !strcasecmp(backsiderequiresflippedmargins->value, "True")) ++ !strcasecmp(backsiderequiresflippedmargins->value, "True")) { ++ dprintf("DEBUG2: (3) Flip: X=1 Y=0\n"); + yflip = 0; +- else ++ } else { ++ dprintf("DEBUG2: (3) Flip: X=1 Y=1\n"); + yflip = 1; ++ } + } + else + { ++ dprintf("DEBUG2: (4) Flip: X=0 Y=0\n"); + xflip = 0; + yflip = 0; + } +@@ -3104,9 +3029,20 @@ cups_put_params(gx_device *pdev, /* + ((strlen(cups->header.cupsPageSizeName) == 0) || + (strcasecmp(cups->header.cupsPageSizeName, size->name) == 0)) && + #endif ++ /* We check whether all 4 margins match with the margin info ++ of the page size in the PPD. Here we check also for swapped ++ left/right and top/bottom margins as the cups->HWMargins ++ info can be from the previous page and there the margins ++ can be swapped due to duplex printing requirements */ + (!margins_set || +- (fabs(cups->HWMargins[0] - size->left) < 1.0 && +- fabs(cups->HWMargins[1] - size->bottom) < 1.0))) ++ (((fabs(cups->HWMargins[0] - size->left) < 1.0 && ++ fabs(cups->HWMargins[2] - size->width + size->right) < 1.0) || ++ (fabs(cups->HWMargins[0] - size->width + size->right) < 1.0 && ++ fabs(cups->HWMargins[2] - size->left) < 1.0)) && ++ ((fabs(cups->HWMargins[1] - size->bottom) < 1.0 && ++ fabs(cups->HWMargins[3] - size->length + size->top) < 1.0) || ++ (fabs(cups->HWMargins[1] - size->length + size->top) < 1.0 && ++ fabs(cups->HWMargins[3] - size->bottom) < 1.0))))) + break; + + if (i > 0) +@@ -3148,9 +3084,20 @@ cups_put_params(gx_device *pdev, /* + ((strlen(cups->header.cupsPageSizeName) == 0) || + (strcasecmp(cups->header.cupsPageSizeName, size->name) == 0)) && + #endif ++ /* We check whether all 4 margins match with the margin info ++ of the page size in the PPD. Here we check also for swapped ++ left/right and top/bottom margins as the cups->HWMargins ++ info can be from the previous page and there the margins ++ can be swapped due to duplex printing requirements */ + (!margins_set || +- (fabs(cups->HWMargins[0] - size->left) < 1.0 && +- fabs(cups->HWMargins[1] - size->bottom) < 1.0))) ++ (((fabs(cups->HWMargins[1] - size->left) < 1.0 && ++ fabs(cups->HWMargins[3] - size->width + size->right) < 1.0) || ++ (fabs(cups->HWMargins[1] - size->width + size->right) < 1.0 && ++ fabs(cups->HWMargins[3] - size->left) < 1.0)) && ++ ((fabs(cups->HWMargins[0] - size->bottom) < 1.0 && ++ fabs(cups->HWMargins[2] - size->length + size->top) < 1.0) || ++ (fabs(cups->HWMargins[0] - size->length + size->top) < 1.0 && ++ fabs(cups->HWMargins[2] - size->bottom) < 1.0))))) + break; + + if (i > 0) +@@ -3258,7 +3205,7 @@ cups_put_params(gx_device *pdev, /* + * Reallocate memory if the size or color depth was changed... + */ + +- if (color_set || size_set) ++ if (color_set || size_set || margins_set) + { + /* + * Make sure the page image is the correct size - current Ghostscript +@@ -3769,13 +3716,22 @@ cups_print_chunked(gx_device_printer *pd + unsigned char *srcptr, /* Pointer to data */ + *dstptr; /* Pointer to bits */ + int count; /* Count for loop */ +- int flip; /* Flip scanline? */ ++ int xflip, /* Flip scanline? */ ++ yflip, /* Reverse scanline order? */ ++ ystart, yend, ystep; /* Loop control for scanline order */ + ppd_attr_t *backside = NULL; + ++ dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); ++ dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble); ++ dprintf1("DEBUG2: cups->page = %d\n", cups->page); ++ dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); ++ + if (cupsPPD) { + backside = ppdFindAttr(cupsPPD, "cupsBackSide", NULL); +- if (backside) ++ if (backside) { ++ dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value); + cupsPPD->flip_duplex = 0; ++ } + } + if (cups->header.Duplex && cupsPPD && + ((!cups->header.Tumble && +@@ -3785,19 +3741,36 @@ cups_print_chunked(gx_device_printer *pd + (backside && (!strcasecmp(backside->value, "Flipped") || + !strcasecmp(backside->value, "ManualTumble"))))) && + !(cups->page & 1)) +- flip = 1; ++ xflip = 1; + else +- flip = 0; ++ xflip = 0; ++ if (cups->header.Duplex && cupsPPD && ++ ((!cups->header.Tumble && ++ (cupsPPD->flip_duplex || ++ (backside && (!strcasecmp(backside->value, "Flipped") || ++ !strcasecmp(backside->value, "Rotated"))))) || ++ (cups->header.Tumble && ++ (backside && !strcasecmp(backside->value, "ManualTumble")))) && ++ !(cups->page & 1)) { ++ yflip = 1; ++ ystart = cups->height - 1; ++ yend = -1; ++ ystep = -1; ++ } else { ++ yflip = 0; ++ ystart = 0; ++ yend = cups->height; ++ ystep = 1; ++ } + +- dprintf2("DEBUG: cups_print_chunked - flip = %d, height = %d\n", +- flip, cups->height); ++ dprintf3("DEBUG: cups_print_chunked: xflip = %d, yflip = %d, height = %d\n", ++ xflip, yflip, cups->height); + + /* + * Loop through the page bitmap and write chunked pixels, reversing as + * needed... + */ +- +- for (y = 0; y < cups->height; y ++) ++ for (y = ystart; y != yend; y += ystep) + { + /* + * Grab the scanline data... +@@ -3809,7 +3782,7 @@ cups_print_chunked(gx_device_printer *pd + gs_exit(gs_lib_ctx_get_non_gc_memory_t(), 1); + } + +- if (flip) ++ if (xflip) + { + /* + * Flip the raster data before writing it... +@@ -3963,13 +3936,22 @@ cups_print_banded(gx_device_printer *pde + unsigned char *srcptr; /* Pointer to data */ + unsigned char *cptr, *mptr, *yptr, /* Pointer to components */ + *kptr, *lcptr, *lmptr; /* ... */ +- int flip; /* Flip scanline? */ ++ int xflip, /* Flip scanline? */ ++ yflip, /* Reverse scanline order? */ ++ ystart, yend, ystep; /* Loop control for scanline order */ + ppd_attr_t *backside = NULL; + ++ dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex); ++ dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble); ++ dprintf1("DEBUG2: cups->page = %d\n", cups->page); ++ dprintf1("DEBUG2: cupsPPD = %p\n", cupsPPD); ++ + if (cupsPPD) { + backside = ppdFindAttr(cupsPPD, "cupsBackSide", NULL); +- if (backside) ++ if (backside) { ++ dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value); + cupsPPD->flip_duplex = 0; ++ } + } + if (cups->header.Duplex && cupsPPD && + ((!cups->header.Tumble && +@@ -3979,12 +3961,30 @@ cups_print_banded(gx_device_printer *pde + (backside && (!strcasecmp(backside->value, "Flipped") || + !strcasecmp(backside->value, "ManualTumble"))))) && + !(cups->page & 1)) +- flip = 1; ++ xflip = 1; + else +- flip = 0; ++ xflip = 0; ++ if (cups->header.Duplex && cupsPPD && ++ ((!cups->header.Tumble && ++ (cupsPPD->flip_duplex || ++ (backside && (!strcasecmp(backside->value, "Flipped") || ++ !strcasecmp(backside->value, "Rotated"))))) || ++ (cups->header.Tumble && ++ (backside && !strcasecmp(backside->value, "ManualTumble")))) && ++ !(cups->page & 1)) { ++ yflip = 1; ++ ystart = cups->height - 1; ++ yend = -1; ++ ystep = -1; ++ } else { ++ yflip = 0; ++ ystart = 0; ++ yend = cups->height; ++ ystep = 1; ++ } + +- dprintf2("DEBUG: cups_print_banded - flip = %d, height = %d\n", +- flip, cups->height); ++ dprintf3("DEBUG: cups_print_chunked: xflip = %d, yflip = %d, height = %d\n", ++ xflip, yflip, cups->height); + + /* + * Loop through the page bitmap and write banded pixels... We have +@@ -4001,7 +4001,7 @@ cups_print_banded(gx_device_printer *pde + bandbytes = cups->header.cupsBytesPerLine / cups->color_info.num_components; + #endif /* CUPS_RASTER_SYNCv1 */ + +- for (y = 0; y < cups->height; y ++) ++ for (y = ystart; y != yend; y += ystep) + { + /* + * Grab the scanline data... +@@ -4021,7 +4021,7 @@ cups_print_banded(gx_device_printer *pde + memset(dst, 0, cups->header.cupsBytesPerLine); + else + { +- if (flip) ++ if (xflip) + cptr = dst + bandbytes - 1; + else + cptr = dst; +@@ -4040,7 +4040,7 @@ cups_print_banded(gx_device_printer *pde + switch (cups->header.cupsColorSpace) + { + default : +- for (x = cups->width, bit = flip ? 1 << (x & 7) : 128; ++ for (x = cups->width, bit = xflip ? 1 << (x & 7) : 128; + x > 0; + x --, srcptr ++) + { +@@ -4051,7 +4051,7 @@ cups_print_banded(gx_device_printer *pde + if (*srcptr & 0x10) + *yptr |= bit; + +- if (flip) ++ if (xflip) + { + if (bit < 128) + bit <<= 1; +@@ -4077,7 +4077,7 @@ cups_print_banded(gx_device_printer *pde + if (*srcptr & 0x1) + *yptr |= bit; + +- if (flip) ++ if (xflip) + { + if (bit < 128) + bit <<= 1; +@@ -4107,7 +4107,7 @@ cups_print_banded(gx_device_printer *pde + case CUPS_CSPACE_CMYK : + case CUPS_CSPACE_YMCK : + case CUPS_CSPACE_KCMY : +- for (x = cups->width, bit = flip ? 1 << (x & 7) : 128; ++ for (x = cups->width, bit = xflip ? 1 << (x & 7) : 128; + x > 0; + x --, srcptr ++) + { +@@ -4120,7 +4120,7 @@ cups_print_banded(gx_device_printer *pde + if (*srcptr & 0x10) + *kptr |= bit; + +- if (flip) ++ if (xflip) + { + if (bit < 128) + bit <<= 1; +@@ -4149,7 +4149,7 @@ cups_print_banded(gx_device_printer *pde + if (*srcptr & 0x1) + *kptr |= bit; + +- if (flip) ++ if (xflip) + { + if (bit < 128) + bit <<= 1; +@@ -4175,7 +4175,7 @@ cups_print_banded(gx_device_printer *pde + } + break; + case CUPS_CSPACE_KCMYcm : +- for (x = cups->width, bit = flip ? 1 << (x & 7) : 128; ++ for (x = cups->width, bit = xflip ? 1 << (x & 7) : 128; + x > 0; + x --, srcptr ++) + { +@@ -4198,7 +4198,7 @@ cups_print_banded(gx_device_printer *pde + if (*srcptr & 0x01) + *lmptr |= bit; + +- if (flip) ++ if (xflip) + { + if (bit < 128) + bit <<= 1; +@@ -4236,7 +4236,7 @@ cups_print_banded(gx_device_printer *pde + switch (cups->header.cupsColorSpace) + { + default : +- for (x = cups->width, bit = flip ? 3 << (2 * (x & 3)) : 0xc0; ++ for (x = cups->width, bit = xflip ? 3 << (2 * (x & 3)) : 0xc0; + x > 0; + x --, srcptr ++) + switch (bit) +@@ -4249,7 +4249,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *yptr |= temp << 6; + +- if (flip) ++ if (xflip) + { + bit = 0x03; + cptr --; +@@ -4267,7 +4267,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *yptr |= temp << 4; + +- if (flip) ++ if (xflip) + bit = 0xc0; + else + bit = 0x0c; +@@ -4280,7 +4280,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *yptr |= temp << 2; + +- if (flip) ++ if (xflip) + bit = 0x30; + else + bit = 0x03; +@@ -4293,7 +4293,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *yptr |= temp; + +- if (flip) ++ if (xflip) + bit = 0x0c; + else + { +@@ -4313,7 +4313,7 @@ cups_print_banded(gx_device_printer *pde + case CUPS_CSPACE_YMCK : + case CUPS_CSPACE_KCMY : + case CUPS_CSPACE_KCMYcm : +- for (x = cups->width, bit = flip ? 3 << (2 * (x & 3)) : 0xc0; ++ for (x = cups->width, bit = xflip ? 3 << (2 * (x & 3)) : 0xc0; + x > 0; + x --, srcptr ++) + switch (bit) +@@ -4328,7 +4328,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *kptr |= temp << 6; + +- if (flip) ++ if (xflip) + { + bit = 0x03; + cptr --; +@@ -4349,7 +4349,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *kptr |= temp << 4; + +- if (flip) ++ if (xflip) + bit = 0xc0; + else + bit = 0x0c; +@@ -4364,7 +4364,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *kptr |= temp << 2; + +- if (flip) ++ if (xflip) + bit = 0x30; + else + bit = 0x03; +@@ -4379,7 +4379,7 @@ cups_print_banded(gx_device_printer *pde + if ((temp = *srcptr & 0x03) != 0) + *kptr |= temp; + +- if (flip) ++ if (xflip) + bit = 0x0c; + else + { +@@ -4401,7 +4401,7 @@ cups_print_banded(gx_device_printer *pde + switch (cups->header.cupsColorSpace) + { + default : +- for (x = cups->width, bit = flip && (x & 1) ? 0xf0 : 0x0f; ++ for (x = cups->width, bit = xflip && (x & 1) ? 0xf0 : 0x0f; + x > 0; + x --, srcptr += 2) + switch (bit) +@@ -4416,7 +4416,7 @@ cups_print_banded(gx_device_printer *pde + + bit = 0x0f; + +- if (flip) ++ if (xflip) + { + cptr --; + mptr --; +@@ -4433,7 +4433,7 @@ cups_print_banded(gx_device_printer *pde + + bit = 0xf0; + +- if (!flip) ++ if (!xflip) + { + cptr ++; + mptr ++; +@@ -4450,7 +4450,7 @@ cups_print_banded(gx_device_printer *pde + case CUPS_CSPACE_YMCK : + case CUPS_CSPACE_KCMY : + case CUPS_CSPACE_KCMYcm : +- for (x = cups->width, bit = flip && (x & 1) ? 0xf0 : 0x0f; ++ for (x = cups->width, bit = xflip && (x & 1) ? 0xf0 : 0x0f; + x > 0; + x --, srcptr += 2) + switch (bit) +@@ -4467,7 +4467,7 @@ cups_print_banded(gx_device_printer *pde + + bit = 0x0f; + +- if (flip) ++ if (xflip) + { + cptr --; + mptr --; +@@ -4487,7 +4487,7 @@ cups_print_banded(gx_device_printer *pde + + bit = 0xf0; + +- if (!flip) ++ if (!xflip) + { + cptr ++; + mptr ++; +@@ -4504,7 +4504,7 @@ cups_print_banded(gx_device_printer *pde + switch (cups->header.cupsColorSpace) + { + default : +- if (flip) ++ if (xflip) + for (x = cups->width; x > 0; x --) + { + *cptr-- = *srcptr++; +@@ -4527,7 +4527,7 @@ cups_print_banded(gx_device_printer *pde + case CUPS_CSPACE_YMCK : + case CUPS_CSPACE_KCMY : + case CUPS_CSPACE_KCMYcm : +- if (flip) ++ if (xflip) + for (x = cups->width; x > 0; x --) + { + *cptr-- = *srcptr++; +@@ -4551,7 +4551,7 @@ cups_print_banded(gx_device_printer *pde + switch (cups->header.cupsColorSpace) + { + default : +- if (flip) ++ if (xflip) + for (x = cups->width; x > 0; x --, srcptr += 6) + { + *cptr-- = srcptr[1]; +@@ -4580,7 +4580,7 @@ cups_print_banded(gx_device_printer *pde + case CUPS_CSPACE_YMCK : + case CUPS_CSPACE_KCMY : + case CUPS_CSPACE_KCMYcm : +- if (flip) ++ if (xflip) + for (x = cups->width; x > 0; x --, srcptr += 8) + { + *cptr-- = srcptr[1]; diff --git a/ghostscript.spec b/ghostscript.spec index 1e3bba6..fcf8f37 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -5,7 +5,7 @@ Summary: A PostScript interpreter and renderer. Name: ghostscript Version: %{gs_ver} -Release: 2%{?dist} +Release: 3%{?dist} # Included CMap data is Redistributable, no modification permitted, # see http://bugzilla.redhat.com/487510 @@ -27,6 +27,7 @@ Patch8: ghostscript-jbig2dec-nullderef.patch Patch9: ghostscript-gs-executable.patch Patch10: ghostscript-CVE-2009-4270.patch Patch11: ghostscript-vsnprintf.patch +Patch12: ghostscript-gdevcups-y-axis.patch Requires: urw-fonts >= 1.1, ghostscript-fonts BuildRequires: xz @@ -123,6 +124,10 @@ rm -rf libpng zlib jpeg jasper # Harden ghostscript's debugging output functions (bug #540760). %patch11 -p1 -b .vsnprintf +# Fixed gdevcups duplex output (bug #541604) by backporting upstream +# revision 10625. +%patch12 -p1 -b .gdevcups-y-axis + # Convert manual pages to UTF-8 from8859_1() { iconv -f iso-8859-1 -t utf-8 < "$1" > "${1}_" @@ -304,6 +309,10 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/libgs.so %changelog +* Thu Jan 21 2010 Tim Waugh 8.70-3 +- Fixed gdevcups duplex output (bug #541604) by backporting upstream + revision 10625. + * Thu Dec 24 2009 Tim Waugh 8.70-2 - Fix debugging output from gdevcups (CVE-2009-4270, bug #540760). - Harden ghostscript's debugging output functions (bug #540760).