summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Schweizer <genstef@gentoo.org>2006-01-15 00:20:39 +0000
committerStefan Schweizer <genstef@gentoo.org>2006-01-15 00:20:39 +0000
commit253145a727f396753bbcf16f54fab52d50f70478 (patch)
treea7cf5cb49c3daee6622aea4ae74ec0f37045e33b /app-text/ghostscript-afpl
parentStable on amd64, bug 113723. (diff)
downloadhistorical-253145a727f396753bbcf16f54fab52d50f70478.tar.gz
historical-253145a727f396753bbcf16f54fab52d50f70478.tar.bz2
historical-253145a727f396753bbcf16f54fab52d50f70478.zip
Add ebuild with hl1250 support thanks to Sebastian Roeder <sebroeder@gmx.de> and Mate Car <mate.car@volja.net> in bug 83279
Package-Manager: portage-2.1_pre3-r1
Diffstat (limited to 'app-text/ghostscript-afpl')
-rw-r--r--app-text/ghostscript-afpl/ChangeLog12
-rw-r--r--app-text/ghostscript-afpl/Manifest6
-rw-r--r--app-text/ghostscript-afpl/files/digest-ghostscript-afpl-8.53-r14
-rw-r--r--app-text/ghostscript-afpl/files/gdevhl12-hl1250.mak16
-rw-r--r--app-text/ghostscript-afpl/files/gdevhl12.c742
-rw-r--r--app-text/ghostscript-afpl/ghostscript-afpl-8.53-r1.ebuild136
6 files changed, 913 insertions, 3 deletions
diff --git a/app-text/ghostscript-afpl/ChangeLog b/app-text/ghostscript-afpl/ChangeLog
index f2e7b49a0d52..42b6d8829558 100644
--- a/app-text/ghostscript-afpl/ChangeLog
+++ b/app-text/ghostscript-afpl/ChangeLog
@@ -1,6 +1,14 @@
# ChangeLog for app-text/ghostscript-afpl
-# Copyright 2000-2005 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/app-text/ghostscript-afpl/ChangeLog,v 1.33 2005/12/23 16:17:32 carlo Exp $
+# Copyright 2000-2006 Gentoo Foundation; Distributed under the GPL v2
+# $Header: /var/cvsroot/gentoo-x86/app-text/ghostscript-afpl/ChangeLog,v 1.34 2006/01/15 00:20:39 genstef Exp $
+
+*ghostscript-afpl-8.53-r1 (15 Jan 2006)
+
+ 15 Jan 2006; Stefan Schweizer <genstef@gentoo.org>
+ +files/gdevhl12-hl1250.mak, +files/gdevhl12.c,
+ +ghostscript-afpl-8.53-r1.ebuild:
+ Add ebuild with hl1250 support thanks to Sebastian Roeder <sebroeder@gmx.de>
+ and Mate Car <mate.car@volja.net> in bug 83279
23 Dec 2005; Carsten Lohrke <carlo@gentoo.org>
ghostscript-afpl-8.53.ebuild:
diff --git a/app-text/ghostscript-afpl/Manifest b/app-text/ghostscript-afpl/Manifest
index bf3a7bdb3161..6ad2cf8206cf 100644
--- a/app-text/ghostscript-afpl/Manifest
+++ b/app-text/ghostscript-afpl/Manifest
@@ -1,10 +1,14 @@
-MD5 bfca1e24f5c8c74b748c5a77f5c4f9b0 ChangeLog 4225
+MD5 cc75e38fc67211e83b8e33d30b12cf00 ChangeLog 4535
MD5 e10b8f4566648e7bc09f6b7336d74b2d files/digest-ghostscript-afpl-8.15 280
MD5 cc1e3a109091c74903b8607870a89016 files/digest-ghostscript-afpl-8.53 281
+MD5 93f779532d9efb34337bc06b23f288d6 files/digest-ghostscript-afpl-8.53-r1 281
MD5 8b3c391af1131b4fce97bef3659e57d3 files/gdevcups.patch 14468
+MD5 e5838642567ec2da6660ef2d6a602cff files/gdevhl12-hl1250.mak 678
+MD5 d17174c7d427aca8d9efa0ef2650845b files/gdevhl12.c 22002
MD5 dbdb3cd0aea8f9032baa11bc335d181a files/gs-8.11-ijs.patch 757
MD5 0a7cbf3d9b9644442d7521969cdb9efd files/gs852-lib.patch 4045
MD5 dbaa6966d91fc14f9460882e8686c44e files/rinkj.patch 1353
MD5 b662c27eb9c0bce8d365d1c081d5af54 ghostscript-afpl-8.15.ebuild 3347
+MD5 6779bde6142c0f38f7001a299133cec1 ghostscript-afpl-8.53-r1.ebuild 3944
MD5 f7d1dac4064e1cb2c7a59d92b0258667 ghostscript-afpl-8.53.ebuild 3683
MD5 26b4b081d538c195dc39bcb2ec8e6f3a metadata.xml 161
diff --git a/app-text/ghostscript-afpl/files/digest-ghostscript-afpl-8.53-r1 b/app-text/ghostscript-afpl/files/digest-ghostscript-afpl-8.53-r1
new file mode 100644
index 000000000000..99673c9de833
--- /dev/null
+++ b/app-text/ghostscript-afpl/files/digest-ghostscript-afpl-8.53-r1
@@ -0,0 +1,4 @@
+MD5 2fbae60417d42779f6488ab897dcaaf6 acro5-cmaps-2001.tar.gz 631653
+MD5 b24576b0097e5457cd8150022d5b4161 adobe-cmaps-200204.tar.gz 2567226
+MD5 4ce09b1dce09b6b9398af0daae9adf63 cups-1.1.23-source.tar.bz2 8705521
+MD5 7b2fca7021a093ce593c04332bcbdfb2 ghostscript-8.53.tar.gz 11745494
diff --git a/app-text/ghostscript-afpl/files/gdevhl12-hl1250.mak b/app-text/ghostscript-afpl/files/gdevhl12-hl1250.mak
new file mode 100644
index 000000000000..8e1421ad1f03
--- /dev/null
+++ b/app-text/ghostscript-afpl/files/gdevhl12-hl1250.mak
@@ -0,0 +1,16 @@
+### -------------------- The Brother HL-1250 printer -------------------- ###
+### This printer is ljet4-compatible, plus support for source tray ###
+### selection and special 1200x600 dpi mode. ###
+
+hl1250_=$(GLOBJ)gdevhl12.$(OBJ) $(HPDLJM)
+$(DD)hl1250.dev : $(hl1250_) $(DD)page.dev
+ $(SETPDEV) $(DD)hl1250 $(hl1250_)
+
+$(DD)hl1240.dev : $(hl1250_) $(DD)page.dev
+ $(SETPDEV) $(DD)hl1240 $(hl1250_)
+
+# Author: Marek Michalkiewicz <marekm@linux.org.pl>
+# Printer: Brother HL-1250 (may work with some other models too)
+$(GLOBJ)gdevhl12.$(OBJ) : $(GLSRC)gdevhl12.c $(PDEVH) $(gdevdljm_h)
+ $(GLCC) $(GLO_)gdevhl12.$(OBJ) $(C_) $(GLSRC)gdevhl12.c
+
diff --git a/app-text/ghostscript-afpl/files/gdevhl12.c b/app-text/ghostscript-afpl/files/gdevhl12.c
new file mode 100644
index 000000000000..f74e28f2c4c2
--- /dev/null
+++ b/app-text/ghostscript-afpl/files/gdevhl12.c
@@ -0,0 +1,742 @@
+/*
+ Contributors:
+ Created by Marek Michalkiewicz <marekm@amelek.gda.pl>
+
+ THIS SOFTWARE IS NOT COPYRIGHTED
+
+ This source code is offered for use in the public domain. You may
+ use, modify or distribute it freely.
+
+ This code is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ DISCLAIMED. This includes but is not limited to warranties of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ (Legalese borrowed from the Mingw32 runtime libraries.)
+ */
+
+/*$Id: gdevhl12.c,v 1.1 2006/01/15 00:20:39 genstef Exp $ */
+/* gdevhl12.c - Brother HL-1250 driver for Ghostscript */
+
+/*
+ This driver handles the 1200x600 dpi mode, and some settings like
+ paper source and toner save mode. 600x600 dpi and below is handled
+ by gdevdljm.c (basically as in the ljet4 device, with minor changes
+ in initialization and margins, and PCL wrapped in PJL).
+
+ There are two device names made available by this driver, which
+ differ only in the default (maximum) resolution:
+
+ -sDEVICE=hl1240
+ 600x600 dpi, for HL-1030/1240 (uses standard PCL modes 2 and 3)
+
+ -sDEVICE=hl1250
+ 1200x600 dpi, for HL-1050/1070/1250/1270N
+ (uses special compression mode 1027 for 1200x600 dpi,
+ otherwise modes 2 and 3 as above)
+
+ Tested with a HL-1250, both 1200x600 and 600x600 dpi. Please test
+ with other models and report results (both problems and success).
+ Some notes on the other models:
+
+ HL-1070 and HL-1270N
+ can also print Postscript directly, at maximum 600x600 dpi
+ (this driver can print 1200x600 dpi using mode 1027).
+
+ HL-1240
+ should no longer be limited to 300 dpi - this driver sends
+ the recommended "@PJL SET RESOLUTION=..." command. PLEASE TEST.
+ There have been some vague problem reports (wrong margins? not
+ clear for what paper size, quite possibly Letter, not A4?) with
+ this printer, if you have it and some Ghostscript hacking skills,
+ _please_ try to help, fix it and send me a patch - thanks!
+
+ HL-1030
+ should no longer be "Paperweight" despite the "for Windows only"
+ warning :-) - it knows enough PCL to print raster graphics, but
+ *requires* "@PJL ENTER LANGUAGE=PCL", so it does not work with
+ the ljet4 driver sending raw PCL. The windows driver uses an
+ undocumented compression mode 1030, but modes 2 and 3 work too.
+ PLEASE TEST.
+
+ New models, still need to be tested:
+ HL-1230 (GDI printer)
+ HL-1440 (GDI printer)
+ HL-1450 (PCL6 and PS2 emulation)
+ HL-1470N (PCL6 and PS2 emulation)
+
+ Additional settings (gs command line options) for this driver:
+
+ -dEconoMode=0...2
+ toner save mode: 0 = disabled (default), 1 = 25%, 2 = 50%
+
+ -dPaperType=0...4
+ paper type: 0 = plain (default), 1 = thin, 2 = thick, 3 = thicker,
+ 4 = transparency
+
+ -dSourceTray=0...4
+ paper source: 0 = auto (default), 1 = dual, 2 = upper, 3 = lower,
+ 4 = manual (not all models support the optional lower tray)
+
+ The 1200x600 dpi mode may require a lot of printer memory - the manual
+ recommends at least 10 MB; for me it seems to work well with 8 MB: 4 MB
+ standard + 4 MB "finally found some good use for that old PS/2 SIMM" :-).
+ Even at just 600x600 dpi (normal PCL 5 control codes) print quality is
+ very good, at 1200x600 dpi it is difficult to see the difference (more
+ visible on grayscale images). So 600x600 dpi is best for general use.
+
+ The HL-1250 also supports PCL 6 (PCL XL) but
+ - I don't have the documentation for that
+ - the pxlmono driver works, but the output looks a bit different
+ from that generated by the ljet4 or (this) 1200x600 dpi driver
+ (lines appear very thin - not yet sure if this is a driver bug
+ or differences in PCL 6 implementation, someone should check on
+ a HP printer, does tiger.ps printed using the ljet4 and pxlmono
+ drivers, both at 600x600 dpi, look the same?)
+ so let's use the good old ljet4 (PCL 5) driver for now.
+ (PCL 6 seems to offer better compression though.)
+
+ To do: the undocumented mode 1030 may offer better compression
+ (may help print complex graphics at 600 dpi - the HL-1030/1240 have
+ only 2 MB of non-expandable RAM, which may not be enough for data
+ that doesn't compress well). The windows driver uses this mode for
+ all models, not just HL-1030. Documentation may be available later.
+
+ Many thanks to Richard Thomas <richardt@brother.co.uk> for help
+ (sending me a HL-1250, documentation, answering my questions).
+
+ Thanks to L. Peter Deutsch <ghost@aladdin.com> for making gdevdjet.c
+ and gdevdljm.[ch] available under a dual AFPL/GPL license.
+ */
+
+#include "gdevprn.h"
+#include "gdevdljm.h"
+
+#ifdef X_DPI
+# define X_DPI2 X_DPI
+#else
+# define X_DPI 600
+# define X_DPI2 1200
+#endif
+
+#ifndef Y_DPI
+# define Y_DPI 600
+#endif
+
+typedef enum {
+ ECONO_OFF = 0,
+ ECONO_25,
+ ECONO_50
+} hl1250_econo_t;
+
+typedef enum {
+ PTYPE_PLAIN = 0,
+ PTYPE_THIN,
+ PTYPE_THICK,
+ PTYPE_THICK2,
+ PTYPE_TRANS
+} hl1250_paper_t;
+
+typedef enum {
+ TRAY_AUTO = 0,
+ TRAY_DUAL,
+ TRAY_UPPER,
+ TRAY_LOWER,
+ TRAY_MANUAL
+} hl1250_tray_t;
+
+typedef struct gx_device_hl1250_s {
+ gx_device_common;
+ gx_prn_device_common;
+ hl1250_econo_t econo_mode;
+ hl1250_paper_t paper_type;
+ hl1250_tray_t source_tray;
+} gx_device_hl1250;
+
+private dev_proc_open_device(hl1250_open);
+private dev_proc_close_device(hl1250_close);
+private dev_proc_print_page_copies(hl1250_print_page_copies);
+private dev_proc_get_params(hl1250_get_params);
+private dev_proc_put_params(hl1250_put_params);
+
+private const gx_device_procs prn_hl1250_procs =
+prn_params_procs(hl1250_open, gdev_prn_output_page, hl1250_close,
+ hl1250_get_params, hl1250_put_params);
+
+#define hl1250_device_copies(dname, xdpi, ydpi)\
+{ prn_device_std_body_copies(gx_device_hl1250, prn_hl1250_procs,\
+ dname,\
+ DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,\
+ xdpi, ydpi,\
+ 0, 0, 0, 0,\
+ 1, hl1250_print_page_copies),\
+ ECONO_OFF, PTYPE_PLAIN, TRAY_AUTO\
+}
+
+const gx_device_hl1250 gs_hl1250_device =
+hl1250_device_copies("hl1250", X_DPI2, Y_DPI);
+
+const gx_device_hl1250 gs_hl1240_device =
+hl1250_device_copies("hl1240", X_DPI, Y_DPI);
+
+/* defines for the 1200x600 dpi mode (mode 1027) */
+
+/* max number of 16-bit words in one 1200 dpi scan line */
+#define SCAN_WORDS 640
+
+/* number of scan lines per band */
+#define BAND_SCANS 64
+
+/* max number of 16-bit words in one 64-line band after compression,
+ limited by 16-bit length field - 7 bytes header + 0xFFF8 bytes data -
+ note that we may have to lose some data if it can't compress well
+ (maximum possible uncompressed data length is about 80K). */
+#define MAX_BAND_WORDS 0x7FFC
+
+/* codes (16-bit words) to send in the 1200x600 dpi data block: */
+
+/* vertical compression (copy COUNT words from the previous line) */
+#define HL_VERT(count) (0xE000 | (count))
+
+/* 16-bit horizontal compression (repeat the next word COUNT times) */
+#define HL_HOR16(count) (0x8000 | (count))
+
+/* 8-bit horiz. compression (repeat DATA byte COUNT*2 times, COUNT < 32) */
+#define HL_HOR8(count, data) (0xC000 | ((count) << 8) | ((data) & 0xFF))
+
+/* 4-bit horiz. compression (repeat DATA nibble COUNT*4 times, COUNT < 512) */
+#define HL_HOR4(count, data) (0xA000 | (count) | (((data) & 0x0F) << 9))
+
+/* no compression, COUNT words of data follow */
+#define HL_COPY(count) ((count) << 4)
+
+typedef unsigned short u16;
+
+/* The printer expects 16-bit data words in big endian order. */
+#if arch_is_big_endian
+#define cpu_to_be16(x) (x)
+#else
+private u16
+cpu_to_be16(u16 x)
+{
+ return (x >> 8) | (x << 8);
+}
+#endif
+
+typedef struct hl1250_state_s {
+ /* smallest area that contains all black dots of the band */
+ /* x = xl..xr-1, y = yt..yb-1, width=xr-xl, height=yb-yt */
+ unsigned int xl, xr, yt, yb;
+
+ /* number of words in the output buffer */
+ unsigned int out_count;
+
+ /* output buffer for compressed data */
+ u16 out_buf[MAX_BAND_WORDS];
+
+ /* input buffer for one 64-line band */
+ u16 in_buf[BAND_SCANS][SCAN_WORDS];
+} hl1250_state_t;
+
+/*
+ find the smallest rectangle that contains all black dots of the
+ band (in other words, the outside of that rectangle is all white)
+ returns 0 if the band is completely white, else 1
+ XXX - it should be faster to scan 32-bit (instead of 16-bit) words
+ */
+private int
+hl1250_check_area(hl1250_state_t * s)
+{
+ unsigned int x, y, xleft, xright, ytop, ybottom;
+ int line_not_white, band_not_white;
+
+ band_not_white = 0;
+ xright = s->xl;
+ xleft = s->xr;
+ ybottom = s->yt;
+ ytop = s->yb;
+ for (y = s->yt; y < s->yb; y++) {
+ line_not_white = 0;
+ for (x = s->xl; x < s->xr; x++) {
+ if (s->in_buf[y][x]) {
+ if (xleft > x)
+ xleft = x;
+ if (xright <= x)
+ xright = x + 1;
+ line_not_white = 1;
+ }
+ }
+ if (line_not_white) {
+ if (ytop > y)
+ ytop = y;
+ if (ybottom <= y)
+ ybottom = y + 1;
+ band_not_white = 1;
+ }
+ }
+ if (band_not_white) {
+ s->xl = xleft;
+ s->xr = xright;
+ s->yt = ytop;
+ s->yb = ybottom;
+ } else {
+ s->xr = s->xl;
+ s->yb = s->yt;
+ }
+ return band_not_white;
+}
+
+/*
+ Compressed data of this band is larger than MAX_BAND_WORDS.
+ Repeat each line using vertical compression, effectively reducing
+ resolution to 1200x300 dpi. This shouldn't happen too often.
+ */
+private void
+hl1250_lose_resolution(hl1250_state_t * s)
+{
+ unsigned int x, y;
+ u16 data0, data1, mask;
+ u16 *out;
+ const u16 *line0;
+ const u16 *line1;
+ unsigned int width = s->xr - s->xl;
+
+ out = s->out_buf;
+ for (y = s->yt; y < s->yb; y += 2) {
+ line0 = &s->in_buf[y][s->xl];
+ line1 = line0;
+ if (y + 1 < s->yb)
+ line1 = &s->in_buf[y + 1][s->xl];
+ mask = (y & 2) ? 0x5555 : 0xAAAA;
+ *out++ = cpu_to_be16(HL_COPY(width));
+ for (x = 0; x < width; x++) {
+ data0 = line0[x];
+ data1 = line1[x];
+ *out++ = (data0 & data1) | (data0 & mask) | (data1 & mask);
+ }
+ *out++ = cpu_to_be16(HL_VERT(width));
+ }
+ s->out_count = out - s->out_buf;
+}
+
+/*
+ Try to compress a single scan line.
+ Return 1 on success, 0 on failure (data doesn't compress
+ well enough to fit in MAX_BAND_WORDS words, truncated).
+ */
+private int
+hl1250_compress_line(hl1250_state_t * s, unsigned int y)
+{
+ unsigned int total_len; /* total data words after compression */
+ unsigned int copy_len; /* number of words to copy uncompressed */
+ unsigned int hlen, vlen; /* length for hor. and vert. compression */
+ unsigned int clen, ulen; /* compressed and uncompressed words */
+ u16 data; /* word currently being processed */
+ u16 hl_code; /* code to send */
+ int x, i;
+ u16 *out;
+ unsigned int width = s->xr - s->xl;
+ const u16 *line = &s->in_buf[y][s->xl];
+ const u16 *prev = (y > s->yt ? &s->in_buf[y - 1][s->xl] : NULL);
+
+ out = &s->out_buf[s->out_count];
+ x = 0;
+ copy_len = 0;
+ total_len = s->out_count;
+ while (x < width) {
+ data = line[x];
+
+ /* how many words (hlen >= 1) to repeat */
+ for (i = x + 1; i < width; i++) {
+ if (line[i] != data)
+ break;
+ }
+ hlen = i - x;
+ /* if not the first line, try vertical compression */
+ vlen = 0;
+ if (prev) {
+ for (i = x; i < width; i++) {
+ if (line[i] != prev[i])
+ break;
+ }
+ vlen = i - x;
+ }
+ /* find the best method to encode the data */
+ ulen = hlen;
+ clen = 1;
+ if (vlen >= hlen) {
+ /* vertical compression */
+ ulen = vlen;
+ hl_code = HL_VERT(vlen);
+ } else if ((data ^ (data >> 8)) & 0xFF) {
+ /* 16-bit horizontal compression */
+ hl_code = HL_HOR16(hlen);
+ clen = 2;
+ } else if ((data ^ (data >> 4)) & 0x0F) {
+ /* 8-bit horizontal compression (if possible) */
+ if (hlen < 32) {
+ hl_code = HL_HOR8(hlen, data);
+ } else {
+ hl_code = HL_HOR16(hlen);
+ clen = 2;
+ }
+ } else {
+ /* 4-bit horizontal compression (if possible) */
+ if (hlen < 512) {
+ hl_code = HL_HOR4(hlen, data);
+ } else {
+ hl_code = HL_HOR16(hlen);
+ clen = 2;
+ }
+ }
+ /*
+ now see if we should copy the word without compression
+ (the cost of leaving/re-entering copy mode is one word).
+ */
+ if (ulen < clen + (copy_len > 0)) {
+ /* yes, copy */
+ copy_len += ulen;
+ } else {
+ if (copy_len) {
+ /* first, copy data (if any) */
+ total_len += copy_len + 1;
+ if (total_len > MAX_BAND_WORDS)
+ goto error_out;
+ *out++ = cpu_to_be16(HL_COPY(copy_len));
+ memcpy(out, &line[x - copy_len], copy_len * sizeof(u16));
+ out += copy_len;
+ copy_len = 0;
+ }
+ /* now send the current code */
+ total_len += clen;
+ if (total_len > MAX_BAND_WORDS)
+ goto error_out;
+ *out++ = cpu_to_be16(hl_code);
+ if (clen == 2) {
+ /* 16-bit compression */
+ *out++ = data;
+ }
+ }
+ /* move to the next word to process */
+ x += ulen;
+ }
+ /* copy anything left at the end */
+ if (copy_len) {
+ total_len += copy_len + 1;
+ if (total_len > MAX_BAND_WORDS)
+ goto error_out;
+ *out++ = cpu_to_be16(HL_COPY(copy_len));
+ memcpy(out, &line[width - copy_len], copy_len * sizeof(u16));
+ out += copy_len;
+ }
+ error_out:
+ s->out_count = out - s->out_buf;
+ return (total_len <= MAX_BAND_WORDS);
+}
+
+/*
+ send a 16-bit big endian value
+ */
+private void
+put_be16(FILE * fp, u16 data)
+{
+ putc(data >> 8, fp);
+ putc(data & 0xFF, fp);
+}
+
+/*
+ prn_stream = data sent to the printer
+ s->xl,xr,yt,yb,in_buf = band (max 64 lines), coordinates band-relative
+ band = Y coordinate of the band from top of page
+ */
+private void
+hl1250_compress_band(FILE * prn_stream, hl1250_state_t * s, unsigned int band)
+{
+ unsigned int y, ytop, ybottom;
+
+ s->out_count = 0;
+
+ if (!hl1250_check_area(s))
+ return;
+
+ /*
+ It seems HL-1250 1200x600 dpi mode has an undocumented feature -
+ it rounds the X left coordinate of the image up to next 32 dots.
+ Probably the RISC inside likes 32-bit alignment. No big problem,
+ we just have to round it down (it's in 16-bit words here).
+ */
+ s->xl &= ~1;
+
+ ytop = s->yt;
+ ybottom = s->yb;
+ for (y = ytop; y < ybottom; y++) {
+ if (hl1250_compress_line(s, y))
+ continue;
+#if 1
+ /* XXX - please report if you ever see this, then change to #if 0 */
+ fprintf(stderr,
+ "hl1250: compression failed (y=%u), doing 1200x300 dpi\n",
+ band + y);
+#endif
+ hl1250_lose_resolution(s);
+ break;
+ }
+ if (s->out_count) {
+ fprintf(prn_stream, "\033*b%uW", s->out_count * sizeof(u16) + 9);
+ put_be16(prn_stream, s->out_count * sizeof(u16) + 7);
+ put_be16(prn_stream, s->xl * 16);
+ put_be16(prn_stream, band + ytop);
+ putc(ybottom - ytop, prn_stream);
+ put_be16(prn_stream, s->xr - s->xl);
+ fwrite(s->out_buf, sizeof(u16), s->out_count, prn_stream);
+ }
+}
+
+
+private int
+hl1250_print_1200dpi(gx_device_printer * pdev, FILE * prn_stream,
+ int num_copies, const char *page_init)
+{
+ int band, lnum;
+ int code = 0;
+ hl1250_state_t *s;
+ int line_size = gdev_prn_raster(pdev);
+ int num_rows = dev_print_scan_lines(pdev);
+ int paper_size = gdev_pcl_paper_size((gx_device *) pdev);
+
+ s = (hl1250_state_t *) gs_alloc_byte_array(pdev->memory, 1, sizeof(*s),
+ "hl1250_print_1200dpi");
+ if (!s)
+ return_error(gs_error_VMerror);
+
+ memset(s, 0, sizeof(*s));
+
+ if (line_size > sizeof(s->in_buf[0]))
+ line_size = sizeof(s->in_buf[0]);
+
+ if (pdev->PageCount == 0) {
+ /* reset, set paper size */
+ fprintf(prn_stream, "\033E\033&l%dA", paper_size);
+ }
+ fputs("\033&u1200D", prn_stream);
+ fputs("\033&l0o0l0E", prn_stream);
+ fputs(page_init, prn_stream);
+ fprintf(prn_stream, "\033&l%dX", num_copies);
+ fputs("\033*rB\033*p0x0Y", prn_stream);
+
+ /* set 600dpi (vertical) resolution */
+ fputs("\033*t600R", prn_stream);
+
+ /* start raster graphics */
+ fputs("\033*r1A", prn_stream);
+
+ /* transfer data in the special 1200x600 dpi format */
+ fputs("\033*b1027M", prn_stream);
+
+ for (band = 0; band < num_rows; band += BAND_SCANS) {
+ int next_band = band + BAND_SCANS;
+
+ if (next_band > num_rows)
+ next_band = num_rows;
+ for (lnum = band; lnum < next_band; lnum++) {
+ code = gdev_prn_copy_scan_lines(pdev, lnum,
+ (byte *) (s->in_buf[lnum - band]), line_size);
+ if (code < 0)
+ goto error_out;
+ }
+ s->yt = 0;
+ s->yb = next_band - band;
+ s->xl = 0;
+ s->xr = 635; /* max width */
+ hl1250_compress_band(prn_stream, s, band);
+ }
+ error_out:
+ fputs("\033*rB\f", prn_stream);
+ gs_free_object(pdev->memory, s, "hl1250_print_1200dpi");
+ return code;
+}
+
+
+private int
+hl1250_open(gx_device * pdev)
+{
+ /* margins: left, bottom, right, top */
+ /* XXX - only A4 tested, letter size margins likely need to be tweaked */
+ static const float margins_a4_600[4] = {0.05, 0.15, 0.25, 0.15};
+ static const float margins_a4_1200[4] = {0.05, 0.2, 0.1, 0.15};
+ static const float margins_letter_600[4] = {0.05, 0.15, 0.25, 0.15};
+ static const float margins_letter_1200[4] = {0.05, 0.2, 0.1, 0.15};
+
+ int x_dpi = (int)((gx_device_printer *) pdev)->x_pixels_per_inch;
+ int paper_size = gdev_pcl_paper_size(pdev);
+
+ if (x_dpi == 1200) {
+ if (paper_size == PAPER_SIZE_A4)
+ gx_device_set_margins(pdev, margins_a4_1200, true);
+ else
+ gx_device_set_margins(pdev, margins_letter_1200, true);
+ } else {
+ if (paper_size == PAPER_SIZE_A4)
+ gx_device_set_margins(pdev, margins_a4_600, false);
+ else
+ gx_device_set_margins(pdev, margins_letter_600, false);
+ }
+ return gdev_prn_open(pdev);
+}
+
+#define UEL "\033%-12345X"
+
+/* XXX - how to get the name of the job (PS file) being printed? */
+#define PJL_JOB_NAME "Ghost"
+
+private int
+hl1250_close(gx_device * pdev)
+{
+ int code = gdev_prn_open_printer(pdev, 1);
+ FILE *fp;
+
+ if (code < 0)
+ return code;
+ fp = ((gx_device_printer *) pdev)->file;
+ /* job separation, reset, UEL */
+ fputs("\033&l1T\033E", fp);
+ fputs(UEL, fp);
+ fprintf(fp, "@PJL EOJ NAME=\"%s\"\r\n", PJL_JOB_NAME);
+ fputs(UEL, fp);
+ return gdev_prn_close(pdev);
+}
+
+
+private int
+hl1250_print_page_copies(gx_device_printer * pdev, FILE * prn_stream,
+ int num_copies)
+{
+ int x_dpi = (int)pdev->x_pixels_per_inch;
+ int y_dpi = (int)pdev->y_pixels_per_inch;
+ const char *tray_pjl;
+ const char *tray_pcl;
+ const gx_device_hl1250 *hl1250 = (gx_device_hl1250 *) pdev;
+ hl1250_econo_t econo_mode = hl1250->econo_mode;
+ hl1250_paper_t paper_type = hl1250->paper_type;
+ hl1250_tray_t source_tray = hl1250->source_tray;
+ static const char * const onoff[2] = { "OFF", "ON" };
+ static const char * const papertypes[5] =
+ { "REGULAR", "THIN", "THICK", "THICK2", "TRANSPARENCY" };
+
+ tray_pjl = "AUTO";
+ tray_pcl = "";
+ switch (source_tray) {
+ case TRAY_DUAL:
+ tray_pcl = "\033&l0H";
+ break;
+ case TRAY_UPPER:
+ tray_pjl = "TRAY1";
+ tray_pcl = "\033&l1H";
+ break;
+ case TRAY_LOWER:
+ tray_pjl = "TRAY2";
+ tray_pcl = "\033&l5H";
+ break;
+ case TRAY_MANUAL:
+ tray_pcl = "\033&l2H";
+ break;
+ default:
+ break;
+ }
+ if (pdev->PageCount == 0) {
+ /* initialize printer */
+ fputs(UEL, prn_stream);
+ fputs("@PJL \r\n", prn_stream);
+ fprintf(prn_stream, "@PJL JOB NAME=\"%s\"\r\n", PJL_JOB_NAME);
+ fprintf(prn_stream, "@PJL SET ECONOMODE=%s\n", onoff[econo_mode != 0]);
+ if (econo_mode)
+ fprintf(prn_stream, "@PJL SET ECONOLEVEL=%d\n", 3 - (int)econo_mode);
+ fprintf(prn_stream, "@PJL SET MEDIATYPE=%s\n", papertypes[paper_type]);
+ fprintf(prn_stream, "@PJL SET SOURCETRAY=%s\n", tray_pjl);
+ fprintf(prn_stream, "@PJL SET RESOLUTION=%d\n", y_dpi);
+ fprintf(prn_stream, "@PJL SET RAS1200MODE=%s\n", onoff[x_dpi == 1200]);
+
+ fputs("@PJL ENTER LANGUAGE=PCL\n", prn_stream);
+ }
+ if (x_dpi != 1200) {
+ char page_init[100];
+
+ /* We get the printer to translate the coordinate system for us.
+ It seems the HL-1250 needs a slightly different translation
+ (-120, 0) compared to the one in the ljet4 driver (-180, 36)
+ (X, Y coordinates here are specified in 1/720-inch units). */
+
+ sprintf(page_init, "\033&l-120U\033*r0F\033&u%dD%s", y_dpi, tray_pcl);
+ return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
+ y_dpi, PCL_LJ4_FEATURES, page_init);
+ }
+ return hl1250_print_1200dpi(pdev, prn_stream, num_copies, tray_pcl);
+}
+
+private int
+hl1250_put_param_int(gs_param_list * plist, gs_param_name pname,
+ int *pvalue, int minval, int maxval, int ecode)
+{
+ int code, value;
+
+ code = param_read_int(plist, pname, &value);
+ switch (code) {
+ case 0:
+ if (value < minval || value > maxval)
+ param_signal_error(plist, pname, gs_error_rangecheck);
+ *pvalue = value;
+ return (ecode < 0 ? ecode : 1);
+ case 1:
+ return ecode;
+ default:
+ return code;
+ }
+}
+
+private int
+hl1250_get_params(gx_device * pdev, gs_param_list * plist)
+{
+ gx_device_hl1250 *hl1250 = (gx_device_hl1250 *) pdev;
+ int code, val;
+
+ code = gdev_prn_get_params(pdev, plist);
+ if (code < 0)
+ return code;
+ val = hl1250->econo_mode;
+ code = param_write_int(plist, "EconoMode", &val);
+ if (code < 0)
+ return code;
+ val = hl1250->paper_type;
+ code = param_write_int(plist, "PaperType", &val);
+ if (code < 0)
+ return code;
+ val = hl1250->source_tray;
+ code = param_write_int(plist, "SourceTray", &val);
+ return code;
+}
+
+private int
+hl1250_put_params(gx_device * pdev, gs_param_list * plist)
+{
+ int code = 0;
+ gx_device_hl1250 *hl1250 = (gx_device_hl1250 *) pdev;
+ int econo_mode = hl1250->econo_mode;
+ int paper_type = hl1250->paper_type;
+ int source_tray = hl1250->source_tray;
+
+ code = hl1250_put_param_int(plist, "EconoMode", &econo_mode,
+ ECONO_OFF, ECONO_50, code);
+ code = hl1250_put_param_int(plist, "PaperType", &paper_type,
+ PTYPE_PLAIN, PTYPE_TRANS, code);
+ code = hl1250_put_param_int(plist, "SourceTray", &source_tray,
+ TRAY_AUTO, TRAY_MANUAL, code);
+ if (code < 0)
+ return code;
+ code = gdev_prn_put_params(pdev, plist);
+ if (code < 0)
+ return code;
+ hl1250->econo_mode = econo_mode;
+ hl1250->paper_type = paper_type;
+ hl1250->source_tray = source_tray;
+ return 0;
+}
diff --git a/app-text/ghostscript-afpl/ghostscript-afpl-8.53-r1.ebuild b/app-text/ghostscript-afpl/ghostscript-afpl-8.53-r1.ebuild
new file mode 100644
index 000000000000..d07464fe60cb
--- /dev/null
+++ b/app-text/ghostscript-afpl/ghostscript-afpl-8.53-r1.ebuild
@@ -0,0 +1,136 @@
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-text/ghostscript-afpl/ghostscript-afpl-8.53-r1.ebuild,v 1.1 2006/01/15 00:20:39 genstef Exp $
+
+inherit eutils
+
+DESCRIPTION="AFPL Ghostscript"
+HOMEPAGE="http://www.cs.wisc.edu/~ghost/"
+
+MY_PN="ghostscript"
+MY_P=${MY_PN}-${PV}
+CUPS_PV=1.1.23
+
+SRC_URI="mirror://sourceforge/ghostscript/${MY_P}.tar.gz
+ cjk? ( http://www.matsusaka-u.ac.jp/mirror/gs-cjk/adobe-cmaps-200204.tar.gz
+ http://www.matsusaka-u.ac.jp/mirror/gs-cjk/acro5-cmaps-2001.tar.gz )
+ cups? ( mirror://gentoo/cups-${CUPS_PV}-source.tar.bz2 )"
+
+LICENSE="Aladdin"
+SLOT="0"
+KEYWORDS="~x86 ~amd64 ~ppc"
+IUSE="X cups cjk gtk jpeg2k"
+
+PROVIDE="virtual/ghostscript"
+
+DEPEND="virtual/libc
+ >=media-libs/jpeg-6b
+ >=media-libs/libpng-1.2.8
+ >=sys-libs/zlib-1.2.1
+ >=media-fonts/gnu-gs-fonts-std-8.11
+ X? ( || ( ( x11-libs/libXt
+ x11-libs/libXpm
+ )
+ virtual/x11
+ )
+ )
+ gtk? ( =x11-libs/gtk+-1.2* )
+ cjk? ( media-fonts/arphicfonts
+ media-fonts/kochi-substitute
+ media-fonts/baekmuk-fonts )
+ cups? ( net-print/cups )
+ jpeg2k? ( media-libs/jasper )
+ !virtual/ghostscript"
+
+S=${WORKDIR}/${MY_P}
+
+src_unpack() {
+ unpack ghostscript-${PV}.tar.gz
+
+ # cups support
+ if use cups; then
+ unpack cups-${CUPS_PV}-source.tar.bz2
+ cp -r cups-${CUPS_PV}/pstoraster ${S}
+ cd ${S}/pstoraster
+ sed -e 's:@prefix@:/usr:' -e 's:@exec_prefix@:${prefix}:' -e 's:@bindir@:${exec_prefix}/bin:' -e 's:@GS@:gs:' pstopxl.in > pstopxl
+ sed -i -e 's:/usr/local:/usr:' pstoraster
+ #81418
+ sed -i 's:OUTPUTFILE="%stdout" $profile $6$:OUTPUTFILE="%stdout" $profile $6 -:' pstoraster
+ sed -i -e "s:pstopcl6:pstopxl:" cups.mak
+ cd ${S}
+ epatch ${FILESDIR}/gdevcups.patch
+ fi
+
+ cd ${S}
+ epatch ${FILESDIR}/gs852-lib.patch
+ # see bug #111537
+ use amd64 || epatch ${FILESDIR}/rinkj.patch
+
+ # enable cfax device (bug #56704)
+ sed -i -e 's:DEVICE_DEVS7=$(DD)faxg3.dev $(DD)faxg32d.dev $(DD)faxg4.dev:DEVICE_DEVS7=$(DD)faxg3.dev $(DD)faxg32d.dev $(DD)faxg4.dev $(DD)cfax.dev:' ${S}/Makefile.in
+
+ # Brother HL-12XX support
+ cp ${FILESDIR}/gdevhl12.c ${S}/src/gdevhl12.c || die
+ cat ${FILESDIR}/gdevhl12-hl1250.mak >> ${S}/src/devs.mak || die
+ sed 's#^\(DEVICE_DEVS6=.*\)$#\1 $(DD)hl1240.dev $(DD)hl1250.dev#' \
+ -i ${S}/src/Makefile.in || die
+}
+
+src_compile() {
+ # don't build gtk frontend if not in use
+ use gtk || sed -i -e 's:$(INSTALL_PROGRAM) $(GSSOX):#:' src/unix-dll.mak \
+ -e 's:$(GSSOX)::' src/unix-dll.mak
+
+ econf \
+ $(use_with X x) \
+ $(use_with jpeg2k jasper) \
+ || die "econf failed"
+# $(use_with ijs) \
+# $(use_with jbig2dec) \
+
+ # build cups driver with cups
+ if use cups; then
+ echo 'include pstoraster/cups.mak' >> Makefile
+ sed -i -e 's:DEVICE_DEVS17=:DEVICE_DEVS17=$(DD)cups.dev:' Makefile
+ sed -i -e 's:LDFLAGS=\(.*\)$(XLDFLAGS):LDFLAGS=\1-L/usr/include -lcups -lcupsimage $(XLDFLAGS):' Makefile
+ fi
+
+ # search path fix
+ sed -i -e "s:\$(gsdatadir)/lib:/usr/share/ghostscript/${PV}/lib:" Makefile
+ sed -i -e 's:$(gsdir)/fonts:/usr/share/fonts/default/ghostscript/:' Makefile
+ sed -i -e "s:\$(gsdatadir)/Resource:/usr/share/ghostscript/${PV}/Resource:" Makefile
+
+ emake || die "emake failed"
+ emake so || die "emake so failed"
+
+ # build ijs
+ cd ijs
+ ./autogen.sh
+ econf --prefix=${D}/usr || die "econf failed"
+ emake || die "emake failed"
+ cd ..
+}
+
+src_install() {
+ einstall install_prefix=${D} soinstall
+
+ rm -fr ${D}/usr/share/ghostscript/${PV}/doc || die
+ dodoc doc/README
+ dohtml doc/*.html doc/*.htm
+ insinto /usr/share/emacs/site-lisp
+ doins doc/gsdoc.el || die
+
+ if use cjk ; then
+ dodir /usr/share/ghostscript/Resource
+ dodir /usr/share/ghostscript/Resource/Font
+ dodir /usr/share/ghostscript/Resource/CIDFont
+ cd ${D}/usr/share/ghostscript/Resource
+ unpack adobe-cmaps-200204.tar.gz
+ unpack acro5-cmaps-2001.tar.gz
+ fi
+
+ # install ijs
+ cd ${S}/ijs
+ dodir /usr/bin /usr/include /usr/lib
+ einstall install_prefix=${D}
+}