--- gs-7.00/src/contrib.mak.orig Sat Apr 7 02:50:27 2001 +++ gs-7.00/src/contrib.mak Sat May 26 00:35:28 2001 @@ -107,6 +107,7 @@ # tek4696 Tektronix 4695/4696 inkjet plotter # uniprint Unified printer driver -- Configurable Color ESC/P-, # ESC/P2-, HP-RTL/PCL mono/color driver +# xe Xerox WorkCentre XE80/82 laser printer # Fax systems: # cfax SFF format for CAPI fax interface # dfaxhigh DigiBoard, Inc.'s DigiFAX software format (high resolution) @@ -764,6 +765,19 @@ $(GLOBJ)gdevtknk.$(OBJ) : $(GLSRC)gdevtknk.c $(PDEVH) $(malloc__h) $(GLCC) $(GLO_)gdevtknk.$(OBJ) $(C_) $(GLSRC)gdevtknk.c +### ---------------- Xerox WorkCentre files ---------------- ### + +### Note: this driver was contributed by a user. ### +### For questions about the xe driver, please contact ### +### Kevin Cozens (kcozens@interlog.com). ### + +xe_=$(GLOBJ)gdevdxe.$(OBJ) +$(DD)xe.dev : $(xe_) $(DD)page.dev + $(SETDEV) $(DD)xe $(xe_) + +$(GLOBJ)gdevdxe.$(OBJ) : $(GLSRC)gdevdxe.c $(PDEVH) + $(GLCC) $(GLO_)gdevdxe.$(OBJ) $(C_) $(GLSRC)gdevdxe.c + ###### ------------------------- Fax devices ------------------------- ###### ### ------------------------- CAPI fax devices -------------------------- ### @@ -877,4 +891,3 @@ $(GLOBJ)gdevsunr.$(OBJ) : $(GLSRC)gdevsunr.c $(PDEVH) $(GLCC) $(GLO_)gdevsunr.$(OBJ) $(C_) $(GLSRC)gdevsunr.c - --- gs-7.00/src/gdevdxe.c.orig Tue Jun 12 00:20:00 2001 +++ gs-7.00/src/gdevdxe.c Tue Jun 12 00:22:27 2001 @@ -0,0 +1,284 @@ +/* Xerox WorkCentre XE 60/62/80/82 multifunction laser printer driver */ +#include "gdevprn.h" + +/* + * You may select a default resolution of 300, or 600 DPI in the makefile, + * or an actual resolution on the gs command line. + * + * If the preprocessor symbol A4 is defined, the default paper size is + * the European A4 size; otherwise it is the U.S. letter size (8.5"x11"). + * + * To determine the proper "margin" settings for your printer, see the + * file align.ps. + */ + +#define MAX_REPEAT 127 /* Values go from 0xFF (repeat of 2) to 0x82 */ +#define MAX_DATA 128 /* A value of 0 means 1 data byte follows */ + +/* + * For all DeskJet Printers: + * + * Maximum printing width = 2400 dots = 8" + * Maximum recommended printing height = 3100 dots = 10 1/3" + * + * The recommendation comes from the HP Software Developer's Guide for + * the DeskJet 500, DeskJet PLUS, and DeskJet printers, version C.01.00 + * of 12/1/90. + * + * Note that the margins defined just below here apply only to the DeskJet; + * the paper size, width and height apply to the LaserJet as well. + */ + +/* Margins are left, bottom, right, top. */ +/* A4 has a left margin of 1/8 inch and a printing width of + * 8 inch this give a right margin of 0.143. The 0.09 top margin is + * not the actual margin - which is 0.07 - but compensates for the + * inexact paperlength which is set to 117 10ths. + * Somebody should check for letter sized paper. I left it at 0.07". + */ +#define XE80_MARGINS_A4 0.167, 0.167, 0.167, 0.167 +#define XE80_MARGINS_LETTER 0, 0, 0, 0 + +#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" */ +#define PAPER_SIZE_A4 26 /* 21.0 cm x 29.7 cm */ +#define PAPER_SIZE_A3 27 /* 29.7 cm x 42.0 cm */ +#define PAPER_SIZE_A2 28 +#define PAPER_SIZE_A1 29 +#define PAPER_SIZE_A0 30 + + +#define magic_hdr "29XJ" + +#define HDR_ITEMS 23 /* Number of items in header */ +#define HDR_PAPER 2 +#define HDR_COPIES 5 +#define HDR_REVERSE 6 +#define HDR_SOURCE 7 +#define HDR_XRES 9 +#define HDR_YRES 10 +#define HDR_XSHIFT 11 +#define HDR_YSHIFT 12 +#define HDR_WIDTH 13 +#define HDR_HEIGHT 14 +#define HDR_BYTES 15 + +long header_data[HDR_ITEMS] = { + 2, /* 2 */ + 96, /* 96 */ + 1, /* Paper type (letter, legal, etc.) */ + 0, /* 0 */ + 0, /* 0 */ + 1, /* Number of copies */ + 0, /* If 1, print in reverse order */ + 1, /* Paper Source (1=Paper Tray, 2=Manual Feed) */ + 0, /* 0 */ + 600, /* X resolution */ + 600, /* Y resolution */ + /* Margin shift is in increments of 0.04" or 1mm at a time */ + 0, /* X margin shift in pixels (+/- 1.72" or +/- 43mm) */ + 0, /* Y margin shift in pixels (+/- 1.72" or +/- 43mm) */ + 4896, /* Page width in pixels 2432/4896 */ + 6400, /* Page height in lines 3200/6400 */ + 800, /* Data bytes per line */ + 0L, /* 0 */ + 0L, /* 0 */ + 0L, /* 0 */ + 0L, /* 0 */ + 0L, /* 0 */ + 0L, /* 0 */ + 0L /* 0 */ +}; + + +/* The device descriptors */ +private dev_proc_open_device(xe_open); +private dev_proc_close_device(xe_close); +private dev_proc_print_page(xe_print_page); + +private const gx_device_procs prn_xe_procs = +prn_params_procs(xe_open, gdev_prn_output_page, xe_close, + gdev_prn_get_params, gdev_prn_put_params); + +const gx_device_printer gs_xe_device = +prn_device(prn_xe_procs, "xe", + DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS, + 600, 600, + 0.0, 0.0, 0.0, 0.0, /* margins filled in by xe_open */ + 1, xe_print_page); + +/* Send a page to the printer. */ +private int xe_print_page( + gx_device_printer * pdev, + FILE * prn_stream); + + +/* Get the paper size code, based on width and height. */ +private int +gdev_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); +} + + +/* Open the printer, adjusting the margins if necessary. */ +private int xe_open(gx_device * pdev) +{ + static const float m_a4[4] = { XE80_MARGINS_A4 }; + static const float m_letter[4] = { XE80_MARGINS_LETTER }; + const float *m = 0; + bool move_origin = true; + + m = gdev_paper_size(pdev) ? m_a4 : m_letter; + move_origin = false; + if (m != 0) + gx_device_set_margins(pdev, m, move_origin); + + return gdev_prn_open (pdev); +} + + +/* xe_close is only here to eject odd numbered pages in duplex mode, */ +/* and to reset the printer so the ink cartridge doesn't clog up. */ +private int xe_close (gx_device * pdev) +{ + int code = gdev_prn_open_printer (pdev, 1); + + if (code < 0) + return code; + return gdev_prn_close (pdev); +} + + +#include /* ~~~~~ */ +#include /* ~~~~~ */ + +/* Send the page to the printer. */ +private int xe_print_page(gx_device_printer *pdev, FILE *prn_stream) +{ + byte *buf, *b, *end; + byte tmp[4]; + int lnum, l, line_size; + int width, height; + int top, bottom, left, right; + int out_cnt, count; + byte *out_ptr; + + line_size = gdev_mem_bytes_per_scan_line (pdev); + height = dev_print_scan_lines (pdev); + + header_data[HDR_XRES] = pdev->x_pixels_per_inch; + header_data[HDR_YRES] = pdev->y_pixels_per_inch; + header_data[HDR_HEIGHT] = height; + header_data[HDR_WIDTH] = line_size * 8; + header_data[HDR_BYTES] = line_size; + + /* The '*2+10' below allows room to hold the compressed data */ + buf = (byte *) gs_malloc (line_size*2+10, 1, "xe_print_page"); + end = buf + line_size - 1; + + /* Check allocation */ + if (!buf) + return_error (gs_error_VMerror); + + /* Default page rectangle */ + top = 0; + left = 0; + right = line_size; + bottom = height-1; + + width = right - left + 1; /* width in bytes */ + height = bottom - top + 1; /* height in pels */ + right = min (line_size - 1, left + width - 1); + end = &buf[line_size*2+9]; /* recompute EOL */ + + /* Print header data */ + fputs(magic_hdr, prn_stream); + for (l = 0; l < HDR_ITEMS; l++) + { + tmp[0] = header_data[l] & 0x000000ff; + tmp[1] = (header_data[l] >> 8) & 0x000000ff; + tmp[2] = (header_data[l] >> 16) & 0x000000ff; + tmp[3] = (header_data[l] >> 24) & 0x000000ff; + fwrite(tmp, sizeof(byte), 4, prn_stream); + } + + /* Print lines of graphics */ + for (lnum = top; lnum <= bottom; ++lnum) + { + gdev_prn_copy_scan_lines (pdev, lnum, &buf[line_size+10], line_size); + + out_cnt = count = 0; + out_ptr = buf; + + b = &buf[line_size+10 + left]; + while (b <= end) + { + tmp[0] = *b++; + ++count; + + l = 1; + if (tmp[0] == *b) + { + /* Build runs of identical characters */ + while (b <= end && l < MAX_REPEAT) + { + if (tmp[0] != *b) + break; + ++b; + ++count; + ++l; + } + + *out_ptr++ = 257-l; + *out_ptr++ = tmp[0]; + out_cnt += 2; + } + else + { + /* Build runs of different characters */ + while (b <= end && l < MAX_DATA) + { + if (b[-1] == *b) + { + --b; + --count; + --l; + break; + } + ++b; + ++count; + ++l; + } + + *out_ptr++ = l - 1; + memmove(out_ptr, &b[-l], l); + out_cnt += l+1; + out_ptr += l; + } + } /* end for b */ + + /* Output the compressed data */ + tmp[0] = out_cnt & 0x00ff; + tmp[1] = (out_cnt >> 8) & 0x00ff; + fwrite(tmp, sizeof(byte), 2, prn_stream); + fwrite(buf, sizeof(byte), out_cnt, prn_stream); + } /* end for lnum */ + + /* We are done */ + fflush (prn_stream); + + gs_free ((char *) buf, line_size, 1, "xe_print_page"); + + return (0); +}