diff -ur gs7.00/lib/align.ps gs7.00.new/lib/align.ps --- gs7.00/lib/align.ps Tue Sep 19 11:29:11 2000 +++ gs7.00.new/lib/align.ps Tue Apr 17 21:32:42 2001 @@ -16,8 +16,8 @@ % copies. % $Id: align.ps,v 1.2 2000/09/19 18:29:11 lpd Exp $ -% Print a page that indicates the proper settings of Margins and HWMargins -% for a given device. Requires a Level 2 system. +% Print a page that indicates the proper settings of Margins, PageOffset, +% and HWMargins for a given device. Requires a Level 3 system. % Reset the offset and margins. @@ -38,7 +38,9 @@ /y1 exch def /x1 exch def pop pop % Draw lines that should be exactly 1" in from each edge, -% and should extend precisely to the edge of the paper. +% and should extend precisely to the edge of the paper. If they +% do not extend to the edge, you may need to add a mechanical +% alignment offset using the Margins parameter. 1 setlinewidth 0 setgray @@ -63,13 +65,16 @@ margins.ps on the gs command line when printing any of your own files: - << /.HWMargins [ml mb mr mt] /Margins [x y] >> setpagedevice +[If L and R are larger than the printer specifications, try to correct +the mechanical alignment offset using the Margins parameter. Do this +before calculating the PageOffset parameters. Not all devices support +the Margins parameter.] + + << /.HWMargins [ml mb mr mt] /PageOffset [x y] >> setpagedevice where ml = L * 72, mb = B * 72, mr = R * 72, mt = T * 72, -%END -/res currentpagedevice /.MarginsHWResolution get def -( x = (1 - H) * ) show res 0 get =string cvs show -(, y = (V - 1) * ) show res 1 get =string cvs show + x = (1 - H) * 72, y = (V - 1) * 72 +%END showpage diff -ur gs7.00/lib/gs_setpd.ps gs7.00.new/lib/gs_setpd.ps --- gs7.00/lib/gs_setpd.ps Wed Nov 1 16:08:13 2000 +++ gs7.00.new/lib/gs_setpd.ps Tue Apr 17 21:43:11 2001 @@ -313,7 +313,7 @@ % Define the keys used in input attribute matching. /.inputattrkeys [ - /PageSize /MediaColor /MediaWeight /MediaType /InsertSheet + /PageSize /MediaColor /MediaWeight /MediaType /InsertSheet /Priority % The following are documented in Adobe's supplement for v2017. /LeadingEdge /MediaClass ] readonly def diff -ur gs7.00/src/devs.mak gs7.00.new/src/devs.mak --- gs7.00/src/devs.mak Fri Mar 16 17:15:42 2001 +++ gs7.00.new/src/devs.mak Tue Apr 17 21:32:42 2001 @@ -541,7 +541,7 @@ ### For questions about the fs600 device, please contact ### ### Peter Schildmann (peter.schildmann@etechnik.uni-rostock.de). ### -HPPCL=$(GLOBJ)gdevpcl.$(OBJ) +HPPCL=$(GLOBJ)gdevpcl.$(OBJ) $(GLOBJ)gdevmeds.$(OBJ) HPDLJM=$(GLOBJ)gdevdljm.$(OBJ) $(HPPCL) HPMONO=$(GLOBJ)gdevdjet.$(OBJ) $(HPDLJM) Only in gs7.00.new/src: devs.mak.orig diff -ur gs7.00/src/gdevdjet.c gs7.00.new/src/gdevdjet.c --- gs7.00/src/gdevdjet.c Tue Sep 19 12:00:12 2000 +++ gs7.00.new/src/gdevdjet.c Tue Apr 17 21:32:42 2001 @@ -345,18 +345,26 @@ ljet3_print_page_copies(gx_device_printer * pdev, FILE * prn_stream, int num_copies) { + char real_init[60]; + + sprintf(real_init, "\033&l%du%dZ\033*r0F", + (int) pdev->Margins[0], (int) pdev->Margins[1]); return dljet_mono_print_page_copies(pdev, prn_stream, num_copies, 300, PCL_LJ3_FEATURES, - "\033&l-180u36Z\033*r0F"); + real_init); } /* LaserJet IIId is same as LaserJet III, except for duplex */ private int ljet3d_print_page_copies(gx_device_printer * pdev, FILE * prn_stream, int num_copies) { + char real_init[60]; + + sprintf(real_init, "\033&l%du%dZ\033*r0F", + (int) pdev->Margins[0], (int) pdev->Margins[1]); return dljet_mono_print_page_copies(pdev, prn_stream, num_copies, 300, PCL_LJ3D_FEATURES, - "\033&l-180u36Z\033*r0F"); + real_init); } /* LaserJet 4 series compresses, and it needs a special sequence to */ /* allow it to specify coordinates at 600 dpi. */ @@ -368,7 +376,9 @@ int dots_per_inch = (int)pdev->y_pixels_per_inch; char real_init[60]; - sprintf(real_init, "\033&l-180u36Z\033*r0F\033&u%dD", dots_per_inch); + sprintf(real_init, "\033&l%du%dZ\033*r0F\033&u%dD", + (int) pdev->Margins[0], (int) pdev->Margins[1], + dots_per_inch); return dljet_mono_print_page_copies(pdev, prn_stream, num_copies, dots_per_inch, PCL_LJ4_FEATURES, real_init); @@ -380,7 +390,9 @@ int dots_per_inch = (int)pdev->y_pixels_per_inch; char real_init[60]; - sprintf(real_init, "\033&l-180u36Z\033*r0F\033&u%dD", dots_per_inch); + sprintf(real_init, "\033&l%du%dZ\033*r0F\033&u%dD", + (int) pdev->Margins[0], (int) pdev->Margins[1], + dots_per_inch); return dljet_mono_print_page_copies(pdev, prn_stream, num_copies, dots_per_inch, PCL_LJ4D_FEATURES, real_init); diff -ur gs7.00/src/gdevdljm.c gs7.00.new/src/gdevdljm.c --- gs7.00/src/gdevdljm.c Tue Sep 19 12:00:12 2000 +++ gs7.00.new/src/gdevdljm.c Tue Apr 17 21:32:42 2001 @@ -106,6 +106,7 @@ int code = 0; bool dup = pdev->Duplex; bool dupset = pdev->Duplex_set >= 0; + int ms = pdev->MediaSource / 100; if (num_copies != 1 && !(features & PCL_CAN_PRINT_COPIES)) return gx_default_print_page_copies(pdev, prn_stream, num_copies); @@ -124,6 +125,9 @@ /* Initialize printer. */ if (pdev->PageCount == 0) { fputs("\033E", prn_stream); /* reset printer */ + /* If the printer supports it, set the media source */ + if ((features & PCL_CAN_SET_MEDIA_TRAY) && (ms != 0)) + fprintf(prn_stream, "\033&l%dH", ms); /* If the printer supports it, set the paper size */ /* based on the actual requested size. */ if (features & PCL_CAN_SET_PAPER_SIZE) { diff -ur gs7.00/src/gdevdljm.h gs7.00.new/src/gdevdljm.h --- gs7.00/src/gdevdljm.h Tue Sep 19 12:00:12 2000 +++ gs7.00.new/src/gdevdljm.h Tue Apr 17 21:32:42 2001 @@ -71,6 +71,7 @@ #define PCL_HAS_DUPLEX 64 /* &lS supported */ #define PCL_CAN_SET_PAPER_SIZE 128 /* &lA supported */ #define PCL_CAN_PRINT_COPIES 256 /* &lX supported */ +#define PCL_CAN_SET_MEDIA_TRAY 512 /* &lH supported */ /* Shorthands for the most common spacing/compression combinations. */ #define PCL_MODE0 PCL3_SPACING @@ -123,12 +124,13 @@ /* H-P LaserJet 4 */ #define PCL_LJ4_FEATURES\ (PCL_MODE3 |\ - PCL_CAN_SET_PAPER_SIZE | PCL_CAN_PRINT_COPIES) + PCL_CAN_SET_PAPER_SIZE | PCL_CAN_PRINT_COPIES | PCL_CAN_SET_MEDIA_TRAY) /* H-P LaserJet 4d */ #define PCL_LJ4D_FEATURES\ (PCL_MODE3 |\ - PCL_HAS_DUPLEX | PCL_CAN_SET_PAPER_SIZE | PCL_CAN_PRINT_COPIES) + PCL_HAS_DUPLEX | PCL_CAN_SET_PAPER_SIZE | PCL_CAN_PRINT_COPIES |\ + PCL_CAN_SET_MEDIA_TRAY) /* H-P 2563B line printer */ #define PCL_LP2563B_FEATURES\ diff -ur gs7.00/src/gdevmeds.c gs7.00.new/src/gdevmeds.c --- gs7.00/src/gdevmeds.c Tue Sep 19 12:00:13 2000 +++ gs7.00.new/src/gdevmeds.c Tue Apr 17 21:32:42 2001 @@ -21,7 +21,7 @@ * Media selection support for printer drivers * * Select from a NULL terminated list of media the smallest medium which is - * almost equal or larger then the actual imagesize. + * almost equal to the actual imagesize. * * Written by Ulrich Schmid, uschmid@mail.hh.provi.de. */ @@ -30,15 +30,14 @@ #define CM * 0.01 #define INCH * 0.0254 -#define TOLERANCE 0.1 CM +#define TOLERANCE 0.005 /* 0.5 percent areal tolerance */ private const struct { const char* name; float width; float height; - float priority; } media[] = { -#define X(name, width, height) {name, width, height, 1 / (width * height)} +#define X(name, width, height) {name, width, height} X("a0", 83.9611 CM, 118.816 CM), X("a1", 59.4078 CM, 83.9611 CM), X("a2", 41.9806 CM, 59.4078 CM), @@ -61,6 +60,7 @@ X("b3", 35.3483 CM, 50.0239 CM), X("b4", 25.0119 CM, 35.3483 CM), X("b5", 17.6742 CM, 25.0119 CM), + X("b5jis", 18.2 CM, 25.7 CM), X("flsa", 8.5 INCH, 13 INCH), X("flse", 8.5 INCH, 13 INCH), X("halfletter", 5.5 INCH, 8.5 INCH), @@ -76,21 +76,24 @@ int select_medium(gx_device_printer *pdev, const char **available, int default_index) { - int i, j, index = default_index; - float priority = 0; + int i, j; + float a,area,tol; float width = pdev->width / pdev->x_pixels_per_inch INCH; float height = pdev->height / pdev->y_pixels_per_inch INCH; + tol = TOLERANCE * width * height; + tol = tol * tol; for (i = 0; available[i]; i++) { for (j = 0; j < sizeof(media) / sizeof(media[0]); j++) { - if (!strcmp(available[i], media[j].name) && - media[j].width + TOLERANCE > width && - media[j].height + TOLERANCE > height && - media[j].priority > priority) { - index = i; - priority = media[j].priority; - } + if (strcmp(available[i], media[j].name)) + continue; + a = (width - media[j].width) * height; + area = a * a; + a = (height - media[j].height) * width; + area += a * a; + if (area < tol) + return(i); } } - return index; + return default_index; } diff -ur gs7.00/src/gdevpcl.c gs7.00.new/src/gdevpcl.c --- gs7.00/src/gdevpcl.c Tue Sep 19 12:00:16 2000 +++ gs7.00.new/src/gdevpcl.c Tue Apr 17 21:32:42 2001 @@ -20,24 +20,61 @@ /* Utilities for PCL printers */ #include "gdevprn.h" #include "gdevpcl.h" +#include "gdevmeds.h" /* ------ Get paper size ------ */ + +/* + * This list must be ordered in ascending order, of the shortest + * side, of available paper sizes. + */ + +static char *paper_names[] = { + "monarch", + "com10", + "dl", + "c5", + "b5", + "b5jis", + "executive", + "a4", + "letter", + "legal", + "b4", + "ledger", + "a3", + "a2", + "a1", + "a0", + 0 +}; + +static int paper_codes[] = { + PAPER_SIZE_MONARCH, + PAPER_SIZE_COM10, + PAPER_SIZE_DL, + PAPER_SIZE_C5, + PAPER_SIZE_B5ISO, + PAPER_SIZE_B5JIS, + PAPER_SIZE_EXECUTIVE, + PAPER_SIZE_A4, + PAPER_SIZE_LETTER, + PAPER_SIZE_LEGAL, + PAPER_SIZE_B4, + PAPER_SIZE_LEDGER, + PAPER_SIZE_A3, + PAPER_SIZE_A2, + PAPER_SIZE_A1, + PAPER_SIZE_A0, + PAPER_SIZE_CUSTOM +}; /* Get the paper size code, based on width and height. */ int gdev_pcl_paper_size(gx_device * dev) { - float height_inches = dev->height / dev->y_pixels_per_inch; - - return - (height_inches >= 33.2 ? PAPER_SIZE_A0 : - height_inches >= 23.5 ? PAPER_SIZE_A1 : - height_inches >= 17.1 ? PAPER_SIZE_A2 : - height_inches >= 16.6 ? PAPER_SIZE_LEDGER : /* see gdevpcl.h */ - height_inches >= 14.1 ? PAPER_SIZE_A3 : - height_inches >= 11.8 ? PAPER_SIZE_LEGAL : - height_inches >= 11.1 ? PAPER_SIZE_A4 : - PAPER_SIZE_LETTER); + return(paper_codes[select_medium(dev, paper_names, + sizeof(paper_names) / sizeof(*paper_names) - 1)]); } /* ------ Color mapping ------ */ diff -ur gs7.00/src/gdevpcl.h gs7.00.new/src/gdevpcl.h --- gs7.00/src/gdevpcl.h Tue Sep 19 12:00:17 2000 +++ gs7.00.new/src/gdevpcl.h Tue Apr 17 21:32:42 2001 @@ -30,6 +30,7 @@ * manual, some documentation calls 11x17 "tabloid" and reserves the name * "ledger" for 17x11. */ +#define PAPER_SIZE_EXECUTIVE 1 #define PAPER_SIZE_LETTER 2 /* 8.5" x 11" */ #define PAPER_SIZE_LEGAL 3 /* 8.5" x 14" */ #define PAPER_SIZE_LEDGER 6 /* 11" x 17" */ @@ -38,6 +39,14 @@ #define PAPER_SIZE_A2 28 #define PAPER_SIZE_A1 29 #define PAPER_SIZE_A0 30 +#define PAPER_SIZE_B5JIS 45 +#define PAPER_SIZE_B4 46 +#define PAPER_SIZE_MONARCH 80 +#define PAPER_SIZE_COM10 81 +#define PAPER_SIZE_DL 90 +#define PAPER_SIZE_C5 91 +#define PAPER_SIZE_B5ISO 100 +#define PAPER_SIZE_CUSTOM 101 /* Get the paper size code, based on width and height. */ int gdev_pcl_paper_size(P1(gx_device *)); diff -ur gs7.00/src/gscoord.c gs7.00.new/src/gscoord.c --- gs7.00/src/gscoord.c Tue Sep 19 12:00:26 2000 +++ gs7.00.new/src/gscoord.c Tue Apr 17 21:32:42 2001 @@ -124,11 +124,6 @@ } dev = gs_currentdevice_inline(pgs); gs_deviceinitialmatrix(dev, pmat); - /* Add in the translation for the Margins. */ - pmat->tx += dev->Margins[0] * - dev->HWResolution[0] / dev->MarginsHWResolution[0]; - pmat->ty += dev->Margins[1] * - dev->HWResolution[1] / dev->MarginsHWResolution[1]; return 0; } diff -ur gs7.00/src/gsdparam.c gs7.00.new/src/gsdparam.c --- gs7.00/src/gsdparam.c Tue Sep 19 12:00:27 2000 +++ gs7.00.new/src/gsdparam.c Tue Apr 17 21:32:42 2001 @@ -163,6 +163,7 @@ (code = param_write_int(plist, "Colors", &colors)) < 0 || (code = param_write_int(plist, "BitsPerPixel", &depth)) < 0 || (code = param_write_int(plist, "GrayValues", &GrayValues)) < 0 || + (code = param_write_int(plist, "%MediaSource", &dev->MediaSource)) < 0 || (code = param_write_long(plist, "PageCount", &dev->PageCount)) < 0 || (code = param_write_bool(plist, ".IgnoreNumCopies", &dev->IgnoreNumCopies)) < 0 || (code = param_write_int(plist, "TextAlphaBits", @@ -432,6 +433,7 @@ gs_param_float_array hwma; gs_param_float_array mhwra; gs_param_string_array scna; + int ms = dev->MediaSource; int nci = dev->NumCopies; int ncset = dev->NumCopies_set; bool ignc = dev->IgnoreNumCopies; @@ -590,6 +592,8 @@ ecode = code; if ((code = param_anti_alias_bits(plist, "GraphicsAlphaBits", &gab)) < 0) ecode = code; + if ((code = param_read_int(plist, "%MediaSource", &ms)) < 0) + ecode = code; /* Ignore parameters that only have meaning for printers. */ #define IGNORE_INT_PARAM(pname)\ @@ -603,7 +607,6 @@ break;\ }\ } - IGNORE_INT_PARAM("%MediaSource") IGNORE_INT_PARAM("%MediaDestination") switch (code = param_read_float_array(plist, (param_name = "ImagingBBox"), &ibba)) { case 0: @@ -733,6 +736,7 @@ dev->color_info.anti_alias.text_bits = tab; dev->color_info.anti_alias.graphics_bits = gab; gx_device_decache_colors(dev); + dev->MediaSource = ms; return 0; } diff -ur gs7.00/src/gxdevcli.h gs7.00.new/src/gxdevcli.h --- gs7.00/src/gxdevcli.h Wed Feb 21 23:27:10 2001 +++ gs7.00.new/src/gxdevcli.h Tue Apr 17 21:32:42 2001 @@ -291,6 +291,7 @@ gx_device_cached_colors_t cached_colors;\ int width; /* width in pixels */\ int height; /* height in pixels */\ + int MediaSource; /* media source dict key */\ float MediaSize[2]; /* media dimensions in points */\ float ImagingBBox[4]; /* imageable region in points */\ bool ImagingBBox_set;\ Only in gs7.00.new/src: gxdevcli.h.orig diff -ur gs7.00/src/gxdevice.h gs7.00.new/src/gxdevice.h --- gs7.00/src/gxdevice.h Tue Sep 19 12:00:36 2000 +++ gs7.00.new/src/gxdevice.h Tue Apr 17 21:32:42 2001 @@ -96,6 +96,7 @@ */ #define std_device_part2_(width, height, x_dpi, y_dpi)\ { gx_no_color_index, gx_no_color_index }, width, height,\ + 0/*media source*/,\ { (((width) * 72.0 + 0.5) - 0.5) / (x_dpi),\ (((height) * 72.0 + 0.5) - 0.5) / (y_dpi) },\ { 0, 0, 0, 0 }, 0/*false*/, { x_dpi, y_dpi }, { x_dpi, y_dpi } diff -ur gs7.00/src/time_.h gs7.00.new/src/time_.h --- gs7.00/src/time_.h Tue Sep 19 12:00:51 2000 +++ gs7.00.new/src/time_.h Tue Apr 17 22:15:53 2001 @@ -38,7 +38,7 @@ */ #ifdef HAVE_SYS_TIME_H # include -# if defined(Plan9) || defined(M_UNIX) || defined(_IBMR2) || defined(_SEQUENT_) /* Plan 9, SCO, AIX and Sequent's DYNIX/ptx need both time.h and sys/time.h! */ +# if defined(Plan9) || defined(M_UNIX) || defined(_IBMR2) || defined(_SEQUENT_) || defined(linux) /* Plan 9, SCO, AIX and Sequent's DYNIX/ptx need both time.h and sys/time.h! */ # include # endif #else