Package-Name: ghostscript
Gentoo-Package: app-text/ghostscript-gpl
Requires: XFree86|Xorg
Homepage: http://www.cs.wisc.edu/~ghost/
Source: sourceforge:///ghostscript/ghostscript-(\d+.\d+).tar.gz $1
# FIXME: we want the "latest version", which may not necessarily be the
# same as the source version
More-Source-1: sourceforge:///ghostscript/ghostscript-fonts-std-8.11.tar.gz
Repack:
	tar xzvfp "$(SOURCE)"
	cd ghostscript-"$(VERSION)" && tar xzvfp "$(SOURCE1)"
Compile:
	cp -af LICENSE doc "$(PREFIX)/"
	$(MAKE) -f ../Makefile configure CONFIGURE_OPTS="--with-x"
	$(MAKE)
	$(MAKE) install
	cp -pfv fonts/* "$(PREFIX)"/share/ghostscript/"$(VERSION)"/lib/
	rm -f "$(PREFIX)"/share/ghostscript/current
	ln -s "$(VERSION)" "$(PREFIX)"/share/ghostscript/current
Install:
	$(MAKE) instbin BIN="bdftops dvipdf eps2eps fixmswrd.pl font2c gs gsbj gsdj gsdj500 gslj gslp gsnd lprsetup.sh pdf2dsc pdf2ps pdfopt pf2afm pfbtopfa printafm ps2ascii ps2epsi ps2pdf ps2pdf12 ps2pdf13 ps2pdf14 ps2pdfwr ps2ps pv.sh unix-lpr.sh wftopfa"
	$(MAKE) instman SECTION=1 MAN="dvipdf eps2eps font2c gs gsbj gsdj gsdj500 gslj gslp gsnd pdf2dsc pdf2ps pdfopt pf2afm pfbtopfa printafm ps2ascii ps2epsi ps2pdf ps2pdf12 ps2pdf13 ps2pdfwr ps2ps wftopfa"
	rm -rf /usr/share/ghostscript
	ln -s "$(PREFIX)"/share/ghostscript /usr/share/
Clean:
	@set -e ; cd "$(PREFIX)"/share/ghostscript ; \
	for i in [0-9]* ; do \
		if [ "$$i" != "$(VERSION)" ] ; then \
			echo "removing \`$(PREFIX)/share/ghostscript/$$i'" ; \
			rm -r "$$i" ; \
		fi ; \
	done
NoPatch: <<EOT
######## begin RPDL driver patch (out of date)
--- ../ghostscript-8.31-orig/Makefile.in	2004-07-29 04:46:59 +0900
+++ Makefile.in	2004-09-02 14:55:21 +0900
@@ -369,7 +369,7 @@
 DEVICE_DEVS3=$(DD)deskjet.dev $(DD)djet500.dev $(DD)laserjet.dev $(DD)ljetplus.dev $(DD)ljet2p.dev $(DD)ljet3.dev $(DD)ljet3d.dev $(DD)ljet4.dev $(DD)ljet4d.dev $(DD)lj5mono.dev $(DD)lj5gray.dev
 DEVICE_DEVS4=$(DD)cdeskjet.dev $(DD)cdjcolor.dev $(DD)cdjmono.dev $(DD)cdj550.dev $(DD)pj.dev $(DD)pjxl.dev $(DD)pjxl300.dev
 DEVICE_DEVS5=$(DD)uniprint.dev @IJSDEVS@
-DEVICE_DEVS6=$(DD)bj10e.dev $(DD)bj200.dev $(DD)bjc600.dev $(DD)bjc800.dev
+DEVICE_DEVS6=$(DD)bj10e.dev $(DD)bj200.dev $(DD)bjc600.dev $(DD)bjc800.dev $(DD)rpdl4.dev
 DEVICE_DEVS7=$(DD)faxg3.dev $(DD)faxg32d.dev $(DD)faxg4.dev
 DEVICE_DEVS8=$(DD)pcxmono.dev $(DD)pcxgray.dev $(DD)pcx16.dev $(DD)pcx256.dev $(DD)pcx24b.dev $(DD)pcxcmyk.dev
 DEVICE_DEVS9=$(DD)pbm.dev $(DD)pbmraw.dev $(DD)pgm.dev $(DD)pgmraw.dev $(DD)pgnm.dev $(DD)pgnmraw.dev $(DD)pnm.dev $(DD)pnmraw.dev $(DD)ppm.dev $(DD)ppmraw.dev $(DD)pkm.dev $(DD)pkmraw.dev $(DD)pksm.dev $(DD)pksmraw.dev
diff -urN ../ghostscript-8.31-orig/doc/README_gdevrpdl4.euc doc/README_gdevrpdl4.euc
--- ../ghostscript-8.31-orig/doc/README_gdevrpdl4.euc	1970-01-01 09:00:00 +0900
+++ doc/README_gdevrpdl4.euc	2004-09-02 14:55:21 +0900
@@ -0,0 +1,376 @@
+
+RICOH RPDL IV Printer driver б
+GNU Ghostscript 6.53 󥹥ȡ
+                                               Version 1.01
+                                               2002/11/08 Ricoh Co.,Ltd.
+
+
+        ܼ
+
+
+  	ܼ
+  	
+  	ե빽
+  	⥸塼
+  	ե륿
+  	/etc/printcap 
+  	Ghostscript ˡ
+  	rpdl4 driver ץ
+	ɥХ
+	ӥ
+	ռ
+
+
+
+	
+
+
+  ʤ Debian GNU/Linux Υѥå˴ޤޤƤ Ghostscript 6.53 
+ RICOH RPDL IV Printer  Linux Ԥ褦ˤ뤿Υɥ饤
+ХǤ
+
+
+	ե빽
+
+
+  COPYING			GNU ̸ͭѵ
+  				http://www.gnu.org/japan/
+  README_gdevrpdl4.euc		
+  gs-gnu_rpdl4			rpdl4 ȹѥ⥸塼
+  printcap			printcap ε
+  rpdl_filter			ե륿ε
+
+  gdevrpdl4.tar.gz
+    gdevrpdl4_install.sh	ӥѥ
+    gdevrpdl4.c			ե
+    gdevrpdl4.mak		make ե
+    gdevrpdl4.diff		ѥåե
+
+
+	⥸塼
+
+
+ 
+  Debian GNU/Linux 3.0 ɸ।󥹥ȡ뤵ƤĶΤоݤ򤷤Ƥ
+ޤC 饤֥꤬ɸѥåʲǤϻѤǤޤ
+
+  ɸѥå
+  ѥå libc6
+  С 2.2.5-6
+
+  (1).  ɥե /tmp Ÿޤ
+        ɥե /tmp ¸ƤΤȤޤ
+
+	$ cd /tmp
+        $ tar xvzf gs_6.53-gdevrpdl4-1.0.tar.gz
+
+  (2).  Debian GNU/Linux 3.0 ° Ghostscript 򥤥󥹥ȡ뤷ޤ
+
+        $ sudo apt-get install gs gsfonts gs-cjk-resource cmap-adobe-ja
+	pan1 cmap-adobe-japan2 defoma psfontmgr ttf-kochi-gothic-naga10
+	ttf-kochi-mincho-naga10
+
+       ջ
+        kochi եȤΰ꤬ޤ
+	嵭եȤ ttf-xtt-watanabe-mincho/ttf-xtt-wadalab-g
+	othic Υ󥹥ȡ򤪴ᤷޤ
+        ޤ嵭ΥեȤ򥤥󥹥ȡ硢ե˽ä
+	Ƥ
+
+	$ cd /usr/share/gs/6.53/
+	$ sudo vi CIDFnmap
+
+	եκǸ
+	/Ryumin-Light		(watanabe-mincho.ttf);
+	/GothicBBB-Medium	(wadalab-gothic.ttf);
+	/HeiseiMin-W3		/Ryumin-Light ;
+	/HeiseiKakuGo-W5	/GothicBBB-Medium ;
+	/HeiseiMin-W3-Acro	/Ryumin-Light ;
+	/HeiseiKakuGo-W5-Acro	/GothicBBB-Medium ;
+
+	Ǿ嵭եȤѤޤ
+
+  (3).  󥹥ȡ뤬λޤ顢GS ⥸塼򥳥ԡޤ
+
+        $ sudo cp /usr/bin/gs-gnu /usr/bin/gs-gnu.org
+	$ sudo cp gs-gnu_rpdl4 /usr/bin/gs-gnu
+
+  (4).  Ghostscript γǧԤޤ
+        ɽޤ
+        $ gs /usr/share/doc/gs/examples/tiger.ps
+
+        ܸɽ򤷤ޤ
+        $ gs /usr/share/doc/gs/examples/cjk/gscjk_aj.ps
+
+  ܸ줬ɽǤƤ˥󥹥ȡ뤬ԤƤޤ
+
+
+	ե륿
+
+
+  (1).  ե륿ޤ
+
+        $ cd /usr/local/lib
+       ʥե륿ΥǤդ˷Ƥ
+        $ sudo vi rpdl_filter
+       ʥե륿̾Ǥդ˷Ƥ
+
+       ε
+        #!/bin/sh
+        /usr/bin/gs -q -dNOPAUSE -dSAFER -sDEVICE=rpdl4 -sPAPERSIZE=a4
+	-sOutputFile=- -
+
+       ڻ͡
+        Ƽ索ץϡ㣸 rpdl4 driver ץ򻲾ȤƤ
+	
+
+  (2).  ե륿˼¹Ը¤Ϳޤ
+
+        $ sudo chmod 755 rpdl_filter
+
+
+	/etc/printcap 
+
+
+  (1).  printcap ޤ
+
+        $ cd /etc
+        $ sudo vi printcap
+
+       ε
+        lp1:\
+           :lp=/dev/lp0:\
+           :sd=/var/spool/lpd/lp1:\
+           :mx#0:\
+           :sh:\
+           :if=/usr/local/lib/rpdl_filter:
+       ʡ㣶ե륿Ǻե륿Υ󡢥ե륿
+         ̾򵭽Ҥޤ
+
+       ª ⡼ȥץ󥿤򤪻Ȥˤʤ
+        lp1:\
+           :rm=192.168.1.1:\    
+           :sd=/var/spool/lpd/lp1:\
+           :mx#0:\
+           :sh:\
+           :lpd_bounce:\
+           :if=/usr/local/lib/rpdl_filter:
+
+       :rm=  :\ ˤϤѤΥץ󥿤ꤵ줿 IP ɥ쥹
+             ϤƤ
+
+  (2).  lprng ǡƵưޤ
+
+        $ sudo /etc/init.d/lprng restart
+
+
+	ˡ
+
+
+  Ghostscriptե륿 printcap ꤬ޤǧΤƥ
+Ȱ򤷤Ƥߤޤ礦
+
+  (1).  ޤ
+        $ lpr /usr/share/doc/gs/examples/tiger.ps
+
+  (2).  ܸޤ
+        $ lpr /usr/share/doc/gs/examples/cjk/gscjk_aj.ps
+
+  ܸ줬ޤ顢ե륿 printcap ꤬ 
+ԤƤޤ
+
+
+	ݣ rpdl4 driver ץ
+
+
+  (1).  ξ̰λ -dDuplex ץ
+        Ĺ֤ξ̡ -dDuplex
+        ̰     -dDuplex=false
+
+        ξ̰ǽäץ󥿤ǤȤ
+
+       
+        /usr/bin/gs -q -dDuplex  -sOutputFile=- -
+
+  (2).  ȥ쥤λ -dManFeed, -dTray ץ
+        ؤ -dManFeed
+        ȥ쥤 -dTray=( 1 - 5 )
+
+       㡧꺹
+        /usr/bin/gs -q -dManFeed  -sOutputFile=- -
+
+       㡧ȥ쥤
+        /usr/bin/gs -q -dTray=2  -sOutputFile=- -
+
+       ջ
+        꺹ȥȥ쥤ƱϽޤ
+
+  (3).  ե४С쥤¹Ԥλ -dFrmOv ץ
+
+        -dFrmOv= ˥ץ󥿤Ͽ줿եֹ 0  99 ꤷޤ
+
+       
+        /usr/bin/gs -q -dFrmOv=99  -sOutputfile=- -
+
+ݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡ
+	ݣGhostscript ץ
+ݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡݡ
+
+  (5).  ٤λ -r ץ
+        240dpi, 400dpi( ǥե ), 600dpi, 1200dpi
+
+        ǶΥץ󥿤򤪻Ȥξϡ400dpi ʾꤷƤ
+        -r ץεҤʤϥǥեͤǽޤ
+
+       
+        /usr/bin/gs -q -r600  -sOutputFile=- -
+
+  (6).  ѻλ -sPAPERSIZE ץ
+
+        Ǥѻ極
+        ѻ : ץ󵭽
+        A3 : a3
+        A4 : a4
+        A5 : a5
+        A6 : a6
+        B4 : b4
+        B5 : b5
+        B6 : b6
+
+       
+        /usr/bin/gs -q  -sPAPERSIZE=a5 -sOutputFile=- -
+
+       ջ
+        ܥץɬܤˤʤޤ
+
+       ڻ͡
+	С B  JIS ѤǤޤ
+	B  JIS ѻѤϲե˽äƤ
+	
+
+	$ cd /usr/share/gs/6.53
+	$ sudo vi gs_statd.ps
+
+	isob5  jisb5 ѹ
+	/isob5 {501 709 //.setpagesize exec} bind def
+	/b5 /isob5 load def
+	Τ褦˥ȥȤޤ
+	/isob5 {501 709 //.setpagesize exec} bind def
+	% /b5 /isob5 load def
+
+	/jisb5 {516 729 //.setpagesize exec} bind def
+	% /b5 /jisb5 load def
+	Τ褦˥Ȥ򳰤ޤ
+	/jisb5 {516 729 //.setpagesize exec} bind def
+	/b5 /jisb5 load def
+
+	ʾѹˤꡢ -sPAPERSIZE=b5  B  JIS Ѳǽ
+	ʤޤ
+
+  (7).  ԡλ -dNumCopies ץ
+
+        -dNumCopies=  2  999 ꤷޤ
+        0  1 ꤹȡ ޤ
+
+       
+        /usr/bin/gs -q -dNumCopies=5  -sOutputfile=- -
+
+
+	ɥХ
+
+
+  ٤̰硢ס֥ˤ뤳Ȥǰ֤ṳ̂Ǥ
+ޤ
+
+  (1).  /etc/printcapԽޤ
+
+        $ sudo vi /etc/printcap
+
+        lp1|Postscript Spool:\
+           :lp=/dev/null:\
+           :sd=/var/spool/lpd/lp1:\
+           :mx#0:\
+           :sh:\
+           :if=/usr/local/lib/rpdl_filter:
+
+        lp2|RPDL Spool:\
+           :lp=/dev/lp0:\
+           :sd=/var/spool/lpd/lp2:\
+           :mx#0:\
+           :sh:
+
+       ­ ⡼Ȥǥץ󥿤򤪻Ȥ
+        lp2|Ghostscript Spool:\
+           :rm=192.168.1.1:\    
+           :sd=/var/spool/lpd/lp2:\
+           :mx#0:\
+           :sh:
+
+       :rm=  :\ ˤϤѤΥץ󥿤ꤵ줿 IP ɥ쥹
+             ϤƤ
+
+  (2).  ե륿Խޤ
+
+        $ sudo vi /usr/local/lib/rpdl_filter
+
+        #!/bin/sh
+        /usr/bin/gs -q -dNOPAUSE -dSAFER -sDEVICE=rpdl4 -sPAPERSIZE=a4
+	-sOutputFile=- - | lpr -Plp2
+
+  (3).  ƥȰ򤷤ޤ
+
+        $ lpr -Plp1 /usr/share/doc/gs/examples/cjk/gscjk_aj.ps
+
+
+	ӥ
+
+
+  (1).  ɤƥӥɤԤޤ
+  
+  	$ cd /tmp
+	$ sudo apt-get -b source gs
+
+  (2). 	rpdl ɥ饤ФȹߤԤޤ
+  
+  	$ sudo ./gdevrpdl4_install.sh
+
+  (3).  ӥɤԤޤ
+  	Υޥɤ¹Ԥȥѥå deb ѥå
+	ӡ changes ե뤬ޤ
+	Υѥåϥեѥåɬפ PGP ̾ά
+	ޤѥåϥץ饤١ȥѥåȤƤ
+	
+
+  	$ cd gs-6.53/
+	$ sudo dpkg-buildpackage -uc -us
+
+  (4).  ѥå򥤥󥹥ȡ뤷ޤ
+
+  	$ sudo dpkg -i gs_6.53-3_i386.deb
+
+  (5).  Ghostscript γǧԤޤ
+        ɽޤ
+        $ gs /usr/share/doc/gs/examples/tiger.ps
+
+        ܸɽ򤷤ޤ
+        $ gs /usr/share/doc/gs/examples/cjk/gscjk_aj.ps
+
+  ܸ줬ɽǤƤ˥󥹥ȡ뤬ԤƤޤ
+
+
+	ռ
+
+
+  ܥɥ饤Фǻͤˤĺ gdevrpdl.c κԤǤ
+ؤμɰؤĲһˤ򿽤夲ޤ
+
+
+	
+
+
+  Ver. 1.01 (2002/11/13)
+  ̥꡼
+  ե४С쥤¹Եǽɲ
+
+  Ver. 1.00 (2002/10/16)
+  ץ꡼
diff -urN ../ghostscript-8.31-orig/src/devs.mak src/devs.mak
--- ../ghostscript-8.31-orig/src/devs.mak	2004-08-05 04:36:12 +0900
+++ src/devs.mak	2004-09-02 14:56:33 +0900
@@ -1573,3 +1573,12 @@
 	$(SETPDEV2) $(DD)tiffsep $(tiffgray_)
 	$(ADDMOD) $(DD)tiffsep -include $(DD)tiffs
 
+### ---------- RICOH RPDL IV printer driver ---------- ###
+
+rpdl4_=$(GLOBJ)gdevrpdl4.$(OBJ)
+
+$(DD)rpdl4.dev : $(rpdl4_) $(DD)page.dev
+	$(SETPDEV) $(DD)rpdl4 $(rpdl4_)
+
+$(GLOBJ)gdevrpdl4.$(OBJ) : $(GLSRC)gdevrpdl4.c $(PDEVH)
+	$(GLCC) $(GLO_)gdevrpdl4.$(OBJ) $(C_) $(GLSRC)gdevrpdl4.c
diff -urN ../ghostscript-8.31-orig/src/gdevrpdl4.c src/gdevrpdl4.c
--- ../ghostscript-8.31-orig/src/gdevrpdl4.c	1970-01-01 09:00:00 +0900
+++ src/gdevrpdl4.c	2004-09-02 14:55:21 +0900
@@ -0,0 +1,496 @@
+/* Copyright (C) 2002 Ricoh Co.,Ltd. All Rights Reserved.
+
+   This file is part of Ghostscript.
+
+   GNU Ghostscript is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
+   to anyone for the consequences of using it or for whether it serves any
+   particular purpose or works at all, unless he says so in writing.  Refer
+   to the GNU General Public License for full details.
+
+   Everyone is granted permission to copy, modify and redistribute
+   this software, but only under the conditions described in the GNU
+   General Public License.  A copy of this license is supposed to have been
+   given to you along with this software so you can know your rights and
+   responsibilities.  It should be in a file named COPYING.  Among other
+   things, the copyright notice and this notice must be preserved on all
+   copies.
+ */
+
+/* gdevrpdl4.c */
+/* Ricoh RPDL IV driver */
+
+/*
+   ռ
+     ܥɥ饤Фǻͤˤĺ gdevrpdl.c κԤǤ
+     ؤμɰĲһˤ򿽤夲ޤ
+ */
+
+#include "gdevprn.h"
+
+#define DPI 400	 
+
+/*
+ * ghostscriptǻѲǽʥץ
+ */
+static struct _rpdl_cont{
+	int BW;		/* block Width  (byte:8dot)	*/
+	int BH;		/* block height (line)		*/
+	int Tray;	/* select tray no. */
+	bool manFeed;	/* select manualfeed */
+	int FrmOv;	/* select formoverlay no. */
+} rpdl_cont =
+{			/* default params	*/
+	1,		/* block width  (byte)	*/
+	24,		/* block height (line)	*/
+	0,		/* tray no. */
+	0,		/* manualfeed */
+	0,		/* formoverlay no. */
+};
+
+/*
+ * ݻ빽¤
+ */
+typedef struct {
+	gx_device_printer *pdev;
+	FILE	*pstream;
+
+	int blw;
+	int blh;
+
+	int x_dpi;
+	int LINE_SIZE;
+	int h;
+	int w;
+} RpdlPageCont;
+
+/* The device descriptors */
+private dev_proc_print_page(paper_size_set);
+private dev_proc_get_params(rpdl_get_params);
+private dev_proc_put_params(rpdl_put_params);
+private void rpdl_page_cont_init(gx_device_printer *pdev, FILE *pstream, RpdlPageCont *cont);
+
+/*
+ * ǥХ
+ */
+private gx_device_procs prn_rpdl_procs =
+prn_params_procs(gdev_prn_open, gdev_prn_output_page, gdev_prn_close,
+		 rpdl_get_params, rpdl_put_params);
+gx_device_printer far_data gs_rpdl4_device =
+prn_device(prn_rpdl_procs, "rpdl4",
+           DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
+           DPI, DPI,		/* x_dpi, y_dpi */
+           0.20, 0.20, 0.20, 0.20,	/* margins */
+           1, paper_size_set);
+
+#define ppdev ((gx_device_printer *)pdev)
+
+private int
+rpdl_get_params(gx_device *pdev, gs_param_list *plist)
+{
+	int code;
+
+	if(ppdev->Duplex_set < 0)
+		ppdev->Duplex_set = 0;
+
+	if((code = gdev_prn_get_params(pdev, plist)) < 0 ||
+	   (code = param_write_int(plist, "BW", &rpdl_cont.BW)) < 0 ||
+	   (code = param_write_int(plist, "BH", &rpdl_cont.BH)) < 0 ||
+	   (code=param_write_bool(plist, "ManFeed", &rpdl_cont.manFeed)) < 0 ||
+	   (code = param_write_int(plist, "Tray", &rpdl_cont.Tray)) < 0 ||
+	   (code = param_write_int(plist, "FrmOv", &rpdl_cont.FrmOv)) < 0
+	   )
+	  return code;
+	return code;
+}
+
+/* put properties. */
+private int
+rpdl_put_params(gx_device *pdev, gs_param_list *plist)
+{
+	param_read_int(plist, "BW", &rpdl_cont.BW);
+	param_read_int(plist, "BH", &rpdl_cont.BH);
+	param_read_bool(plist, "ManFeed", &rpdl_cont.manFeed);
+	param_read_int(plist, "Tray", &rpdl_cont.Tray);
+	param_read_int(plist, "FrmOv", &rpdl_cont.FrmOv);
+	gdev_prn_put_params(pdev, plist);
+	return 0;
+}
+
+/*
+ * 
+ */
+private void rpdl_page_cont_init(gx_device_printer *pdev, FILE *pstream,
+				 RpdlPageCont *cont)
+{
+	cont->pdev = pdev;
+	cont->pstream = pstream;
+
+	cont->blw = rpdl_cont.BW;
+	if(cont->blw < 1) cont->blw = 1;
+	cont->blh = rpdl_cont.BH;
+	if(cont->blh < 1) cont->blh = 24;
+
+	cont->x_dpi = pdev->x_pixels_per_inch;
+	cont->LINE_SIZE = 
+		(pdev->x_pixels_per_inch * 2970 / 254 / 8 + 1);
+	cont->h = pdev->height;
+	cont->w = gdev_prn_raster(pdev);
+}
+
+#define	SUB 0x1a
+#define ESC 0x1b
+#define	DC2 0x12
+#define	EM  0x19
+
+int nPrintCount;
+int nPrintBlock;
+int nTotalBlock;
+
+/*
+  Send the block to the printer. 
+    pstream: 	output file 
+    bw: 	width in byte
+    bh: 	height in dot
+    x : 	start x position in byte
+    y : 	start y position in dot
+    row_buf: 	data buffer
+    w:		line length in byte
+*/
+private int
+rpdl_print_block(RpdlPageCont *cont, int bw, int bh, int x, int y, char* row_buf)
+{
+	char block_data[cont->blh * cont->LINE_SIZE];
+	char comp_data[cont->blh * cont->LINE_SIZE * 2];
+	int total_size = bw * bh;
+	int compress = 0;
+	char *bgn_data;
+	int c, count, i, j;
+	char *rp, *cp, *sp;
+
+	/* compress */
+	sp = block_data;
+	cp = comp_data;
+	c = *(row_buf + x) + 1;
+	count = 1;
+	for(j = 0; j < bh; j++, sp += bw) {
+		rp = row_buf + cont->w * j + x;
+		memcpy(sp, rp, bw);
+		for(i = 0; i < bw; i++, rp++) {
+			if(*rp == c) {
+				count++;
+				if(count == 258) {
+					*cp++ = c;
+					*cp++ = (char)255;
+					*cp++ = c;
+					count = 1;
+				}
+			} else {
+				if(count > 1) {
+					*cp++ = c;
+					*cp++ = count - 2;
+					count = 1;
+				}
+				*cp++ = c = *rp;
+			}
+        	}
+	}
+	if(count > 1) {
+		*cp++ = c;
+		*cp++ = count - 2;
+	}
+
+	/* check whether use compress data or not */
+	if(total_size > cp - comp_data) {
+		bgn_data = comp_data;
+		total_size = cp - comp_data;
+		compress = 4;
+	} else {
+		bgn_data = block_data;
+		total_size = bw * bh;
+		compress = 0;
+	}
+
+	/* move */
+	fprintf(cont->pstream, "%c%cG3,%d,%d,1,%d,%d,%d,%d@", ESC, DC2, 
+		bw*8,		/* dots per line */
+		bh,		/* lines */
+		compress,	/* compress type */
+		x*8,		/* start position */
+		y,		/* start line position */
+		total_size	/* data size */
+	);
+
+	/* send the block */
+	fwrite(bgn_data, sizeof(char), total_size, cont->pstream);
+
+	return 0;
+}
+
+/* Send the page to the printer.  */
+private int
+rpdl_print_page(RpdlPageCont *cont)
+{
+
+	/* devide all lines in several blocks */
+	int bh, bw, x, y, first_x, block_width;
+
+	char row_buf[cont->blh * cont->LINE_SIZE];
+
+	nPrintCount = nPrintBlock = nTotalBlock = 0;
+
+	/* print blocks */
+	for(y = 0; y < cont->h; y += cont->blh) {
+		bh = cont->h - y;
+		if(bh > cont->blh) 
+			bh = cont->blh;
+
+		gdev_prn_copy_scan_lines(cont->pdev, y, row_buf, bh * cont->w);
+
+		first_x = -1;
+		block_width = 0;
+		for(x = 0; x < cont->w; x += cont->blw) {
+			bw = cont->w - x;
+			if(bw > cont->blw)
+				bw = cont->blw;
+
+			nTotalBlock++;
+			/* skip white block */
+			{
+				int i, j;
+				for(j = 0; j < bh; j++) {
+					char* rp = row_buf + j * cont->w + x;
+					for(i = 0; i < bw; i++, rp++) {
+						if(*rp) {
+							goto has_data;
+						}
+					}
+				}
+				if(block_width) {
+					rpdl_print_block(cont,
+						block_width, bh,
+						first_x, y,
+						row_buf);
+					nPrintCount++;
+					block_width = 0;
+					first_x = -1;
+				} 
+				continue; 
+			}
+has_data:
+			if(first_x == -1) {
+				first_x = x;
+			}
+			block_width += bw;
+			nPrintBlock++;
+
+		}
+		if(block_width) {
+			rpdl_print_block(cont,
+				block_width, bh,
+				first_x, y,
+				row_buf);
+			nPrintCount++;
+		}
+	}
+
+	/* print page */
+	fputc(0x0C, cont->pstream);
+
+	return 0;
+}
+
+private int
+rpdl_print_init(gx_device_printer *pdev, FILE *pstream, const char* paper_size)
+{
+	/* paper size */
+	static char RpdlInit[] = {
+		/* RPDL mode */
+		ESC, DC2, '!', '@', 'R', '0', '0', ESC, ' ',
+		/* printer reset */
+		ESC, SUB, 'I',
+		/* graphics (400dpi) */
+		ESC, DC2, 'Y', 'W', ',', '1', ' ',
+		/* engine (400dpi) */
+		ESC, DC2, 'Y', 'A', '0', '4', ',', '1', ' ',
+		/* paper size A4 */
+		ESC, DC2, '5', '3', '@', 'A', '4', 'X', ESC, ' ',
+		/* portlait */
+		ESC, DC2, 'D', '1', ' ',
+		/* coordination unit (400dpi) */
+		ESC, DC2, '#', '2', ' ',
+		/* spaceing unit (400dpi) */
+		ESC, DC2, 'Q', '4', ' ',
+		/* Duplex */
+		ESC, DC2, '6', '0', ',', '0', ',', '0', ' ',
+		/* Formoverlay */
+		ESC, DC2, 'U', '0', '0', ' ',
+	};
+
+	RpdlPageCont cont;
+	int dpi;
+	char fo_no[2];
+
+	if(pdev->PageCount == 0){
+		dpi = pdev->x_pixels_per_inch;
+
+		switch(dpi) {
+		case 400: 
+			/* graphics dpi, 1:400
+					 2:240
+					 3:600
+					 4:1200 */
+			RpdlInit[17] = '1';
+
+			/* engine dpi, 1:400
+				       2:240
+			 	       3:600
+				       4:1200 */
+			RpdlInit[26] = '1';
+
+			/* coordination unit, 0:720
+				              1:720
+					      2:400
+					      3:240
+					      4:600
+					      5:1200 */
+			RpdlInit[46] = '2';
+
+			/* spacing unit, 0:240
+					 1:??
+					 2:720
+					 3:300
+					 4:400
+					 5:600
+					 6:1200 */
+			RpdlInit[51] = '4';
+			break;
+
+		case 600: 
+			RpdlInit[17] = '3';
+			RpdlInit[26] = '3';
+			RpdlInit[46] = '4'; 
+			RpdlInit[51] = '5'; 
+			break;
+
+		case 1200: 
+			RpdlInit[17] = '4';
+			RpdlInit[26] = '4';
+			RpdlInit[46] = '5'; 
+			RpdlInit[51] = '6'; 
+			break;
+
+		case 240: 
+			RpdlInit[17] = '2'; 
+			RpdlInit[26] = '2'; 
+			RpdlInit[46] = '3'; 
+			RpdlInit[51] = '0';
+			break;
+
+		default: /* same as 400dpi */ 
+			RpdlInit[17] = '1';
+			RpdlInit[26] = '1';
+			RpdlInit[46] = '2'; 
+			RpdlInit[51] = '4'; 
+			break;
+		}
+
+		/* set paper size */
+		memcpy(&RpdlInit[33], paper_size, 2);
+
+		/* Duplex */
+		if(pdev->Duplex_set > 0){
+			if(pdev->Duplex){
+				RpdlInit[56] = '1';
+			} else {
+				RpdlInit[56] = '0';
+			}
+		}
+
+		/* Select FormOverley */
+		if(rpdl_cont.FrmOv >= 0){
+			sprintf(fo_no, "%02d", rpdl_cont.FrmOv);
+			memcpy(&RpdlInit[65], fo_no, 2);
+		}
+
+		/* initialize */
+		fwrite(RpdlInit, sizeof(RpdlInit), 1, pstream);
+
+		/* Select Tray */
+		if(rpdl_cont.manFeed){
+			fprintf(pstream, "%c%cT", ESC, EM);
+		} else {
+			if(rpdl_cont.Tray > 0){
+				switch(rpdl_cont.Tray){
+				case 1:
+					fprintf(pstream, "%c%c2", ESC, EM);
+					break;
+				case 2:
+					fprintf(pstream, "%c%c3", ESC, EM);
+					break;
+				case 3:
+					fprintf(pstream, "%c%c4", ESC, EM);
+					break;
+				case 4:
+					fprintf(pstream, "%c%c5", ESC, EM);
+					break;
+				case 5:
+					fprintf(pstream, "%c%c6", ESC, EM);
+					break;
+				default:
+					break;
+				}
+			}
+		}
+
+	}
+
+	rpdl_page_cont_init(pdev, pstream, &cont);
+	return rpdl_print_page(&cont);
+}
+
+/*
+ * ѻ極ݻ빽¤
+ */
+typedef struct {
+	int width;
+	int height;
+	int count;
+	char name[2];
+} RpdlPaperTable;
+
+static RpdlPaperTable rpdlPaperTable[] =
+{
+  { 612,  792,  1, "LT"}, /* letter */
+  { 612, 1008,  2, "LG"}, /* legal */
+  { 842, 1190,  3, "A3"}, /* a3 */
+  { 595,  842,  4, "A4"}, /* a4 */
+  { 597,  842,  5, "A4"}, /* a4 8.3inch * 11.7inch */
+  { 421,  595,  6, "A5"}, /* a5 */
+  { 297,  421,  7, "A6"}, /* a6 */
+  { 709, 1002,  8, "B4"}, /* b4 */
+  { 501,  709,  9, "B5"}, /* b5 */
+  { 729, 1032, 10, "B4"}, /* jisb4 */
+  { 516,  729, 11, "B5"}, /* jisb5 */
+  { 363,  516, 12, "B6"}, /* jisb6 */
+  {   0,    0, -1, "A4"}  /* error */
+};
+
+private int
+paper_size_set(gx_device_printer *pdev, FILE *pstream)
+{
+	int width, height;
+	char paper_size[2];
+	RpdlPaperTable *pt;
+
+	width  = pdev->MediaSize[0];
+	height = pdev->MediaSize[1];
+
+	for(pt = rpdlPaperTable; pt->count > 0; pt++)
+		if(pt->width == width && pt->height == height)
+			break;
+
+	memcpy(paper_size, pt->name, 2);
+
+	return rpdl_print_init(pdev, pstream, paper_size);
+}
######## end RPDL driver patch
EOT

/pkg/ghostscript/
/usr/bin/bdftops
/usr/bin/dvipdf
/usr/bin/eps2eps
/usr/bin/fixmswrd.pl
/usr/bin/font2c
/usr/bin/gs
/usr/bin/gsbj
/usr/bin/gsdj
/usr/bin/gsdj500
/usr/bin/gslj
/usr/bin/gslp
/usr/bin/gsnd
/usr/bin/lprsetup.sh
/usr/bin/pdf2dsc
/usr/bin/pdf2ps
/usr/bin/pdfopt
/usr/bin/pf2afm
/usr/bin/pfbtopfa
/usr/bin/printafm
/usr/bin/ps2ascii
/usr/bin/ps2epsi
/usr/bin/ps2pdf
/usr/bin/ps2pdf12
/usr/bin/ps2pdf13
/usr/bin/ps2pdf14
/usr/bin/ps2pdfwr
/usr/bin/ps2ps
/usr/bin/pv.sh
/usr/bin/unix-lpr.sh
/usr/bin/wftopfa
/usr/man/man1/dvipdf.1.gz
/usr/man/man1/eps2eps.1.gz
/usr/man/man1/font2c.1.gz
/usr/man/man1/gs.1.gz
/usr/man/man1/gsbj.1.gz
/usr/man/man1/gsdj.1.gz
/usr/man/man1/gsdj500.1.gz
/usr/man/man1/gslj.1.gz
/usr/man/man1/gslp.1.gz
/usr/man/man1/gsnd.1.gz
/usr/man/man1/pdf2dsc.1.gz
/usr/man/man1/pdf2ps.1.gz
/usr/man/man1/pdfopt.1.gz
/usr/man/man1/pf2afm.1.gz
/usr/man/man1/pfbtopfa.1.gz
/usr/man/man1/printafm.1.gz
/usr/man/man1/ps2ascii.1.gz
/usr/man/man1/ps2epsi.1.gz
/usr/man/man1/ps2pdf.1.gz
/usr/man/man1/ps2pdf12.1.gz
/usr/man/man1/ps2pdf13.1.gz
/usr/man/man1/ps2pdfwr.1.gz
/usr/man/man1/ps2ps.1.gz
/usr/man/man1/wftopfa.1.gz
/usr/share/ghostscript
