From: shiohara@tppio.tpp.epson.co.jp (Susumu Shiohara)
Newsgroups: fj.comp.printers
Subject: Re: EPSON LP2000
Date: 3 Sep 92 10:25:13 GMT
Distribution: fj
Organization: SEIKO EPSON Corp., Nagano, Japan

In article <YOSHI.92Sep3051709@biorobot.mse.kyutech.ac.jp> yoshi@biorobot.mse.kyutech.ac.jp writes:
>$B>>:j!w6e=#9)Bg$H?=$7$^$9!#(J
>
>$B8&5f<<$N#E#P#S#O#N(J $B#L#P#2#0#0#0$r#S#P#A#R#C!!#E#L#C$K$D$J$$$G$$$^$9!#(J
>$B$7$+$7!"F|K\8l$,$&$^$/=P$;$J$$$N$G$9!#(J
>$B#t#e#x#t$N4A;z%3!<%I$r$$$m$$$mJQ$($F$b!"$9$Y$F2=$1$F=P$FMh$^$9!#(J
>$B#L#P#2#0#0#0$N$[$&$O!"4A;z%3!<%I$rJQ$($i$l$J$$!J#J#I#S$7$+$J$$$N$G$O!K(J

$B0JA0$+$i(JWS$B$K$D$J$$$G;HMQ$7$F$$$k$N$G;29M$^$G$K>R2p$7$^$9!#(J
$B$?$@$7C1=c$J%F%-%9%H$N=PNO$N$_$K;HMQ$7$F$$$^$9!#(J
tex$B$J$I$N%U%#%k%?!<$O;DG0$J$,$i:n@.$7$F$"$j$^$;$s!#(J

$B$^$:(J/etc/printcap$B$K0J2<$NFbMF$rIU$12C$($^$9(J
$B$_$=$O!"=PNOMQ$K%U%#%k%?$r@_Dj$9$k$3$H$G$9!#(J

	:of= $B$N9T$,$=$l$G$9!#(J

$B$3$l$O(JSONY-NEWS($B%;%s%H%m(J)$BMQ$G$9$,!"(JSUN$B$G$b$@$$$?$$F1$8$@$H;W$$$^$9!#(J
$B;29M$K$7$F$/$@$5$$!#(J

#
#	EPSON Page Printer LP2000(ESC/PageTM)
#
lp1|lp2000|local laser printer:\
	:lp=/dev/lp0:\
	:sd=/usr/spool/lpd:\
	:lf=/usr/adm/lpd-errs:\
	:of=/usr/local/lpdfilters/lp2000f:\
	:ct=:\
	:pl#87:pw#116:\
	:sb:sh:\
	:ff"\":
#
#
$B0J2<$O(Jlp2000f.c$B$NFbMF$G$9!#(Jcc -o lp2000f lp2000f.c $B$G$G$-$^$9!#(J
$B$3$l$r(J /usr/local/lpdfilters$B$K$*$1$P40N;$G$9!#(J

$B0l1~!"(Jman$B$J$I$G%U%!%$%k$KMn$H$7$?%F%-%9%H$b=PNO$G$-$k$h$&$K$7$F$"$j$^$9!#(J
$B;29M$K$7$F2<$5$$!#(J

-------------- $B$3$3$+$i(J -----------------
#include <stdio.h>
#define	sjis_kanji(c)	((c)>=0x81 && (c)<0x9f || (c)>0xe0 && (c)<=0xfc )
#define euc_kanji(c)	((c) > 0xa0 && (c) != 0xaa)
#define euc_kana(c)	((c) == 0x8e) || (c) >= 0xa1 && (c) <= 0xfe)
#define ESC	0x1b
#define FS	0x1c
#define GS	0x1d
#define BS	0x08
#define LF	0x0a
#define CR	0x0d


void euc_to_jis(jh, jl, eh, el)
int *jh, *jl;
int eh, el;
{
	int h,l;
	h=eh; l=el;	

	h -= 0x80; l -= 0x80;
	*jh=h; *jl=l;
}

void sjis_to_jis(jh, jl, sh,sl)
int *jh, *jl;
int sh, sl;
{
	int h,l;
	h=sh; l=sl;	

	if( h>=0xe0 && h<=0xfc) h -= 0xb0;
	else h -= 0x70;

	h *= 2;
	if(l>=0x80) l--;
	if(l>=0x9e) l -= 0x7d;
	else {
		h--;
		l -= 0x1f;
	}

	*jh=h; *jl=l;
}

main(argc,argv)
int  argc;
char *argv[];
{
	int	first_f, kanji_f, bs_f, pre_bs_f, kanji_c;
	int	c, d, jh, jl, pre_c, pre_jh, pre_jl;
	int	kcode;

	/* ESC/PS -> ESC/P */
	putchar(ESC);printf("S");putchar(ESC);
	putchar(ESC);printf("S");putchar(FS);

	/* ESC/P -> ESC/Page */
	putchar(ESC);printf("z");putchar(NULL);putchar(NULL);

	putchar(GS);printf("rhE");	/* parameter reset */
	putchar(GS);printf("0mmE");	/* Band mode */
	putchar(GS);printf("0poE");	/* orientation portlay */
	putchar(GS);printf("2;1muE");	/* set minimum unit */
	putchar(GS);printf("20;7.5loE");/* set origin */
	putchar(GS);printf("tmE");	/* set top margine */
	putchar(GS);printf("280bmE");	/* set bottom margine */
	putchar(GS);printf("3.2lpP");	/* set line feed */
	putchar(GS);printf("3.39pP");	/* set pitch */
	putchar(GS);printf("pmP");	/* set pitch off */
	putchar(GS);printf("0weF");	/* normal weight */

	first_f=1;			/* set first flag */
	kanji_f=0;			/* reset flag */
	kanji_c=0;			/* reset flag */
	bs_f=pre_bs_f=0;		/* reset flag */
	pre_c=pre_jh=pre_jl=0;		/* reset code */
	kcode = -1;

	while((c=getchar()) != EOF) {

		if(kcode == -1){
			if(sjis_kanji(c)) {
				kanji_c = 1;
				kcode = 1;
			}
			else if(euc_kanji(c)) {
				kanji_c = 2;
				kcode = 2;
			}
			else kanji_c = 0;
		}
		else if(kcode == 1) {
			if(sjis_kanji(c)) {
				kanji_c = 1;
			}
			else kanji_c = 0;
		}
		else if(kcode == 2) {
			if(euc_kanji(c)) {
				kanji_c = 2;
			}
			else kanji_c = 0;
		}

		if(kanji_c != 0) {

			if(first_f == 1 || kanji_f == 0){
				putchar(GS);printf("1;2ssF");	/* select 2byte code */
				putchar(GS);printf("9.37wcF");	/* select 9.37 CPI Font */
				putchar(GS);printf("7.68hpF");	/* select 7.68 Point Font */
				putchar(GS);printf("10tfF");	/* select MINCHO */
				putchar(GS);printf("1pmP");	/* set pitch on */
				first_f=0;			/* clear first flag */
				kanji_f=1;			/* set 2byte code flag */
			}

			d=getchar();
			if(kanji_c == 1) sjis_to_jis(&jh, &jl, c, d);	/* convert SJIS to JIS */
			if(kanji_c == 2) euc_to_jis(&jh, &jl, c, d);	/* convert EUC to JIS */
			kanji_c = 0;

			if(pre_bs_f == 0) {			/* not BS(Bold) */
				putchar(jh); putchar(jl);	/* send datas */
				pre_jh=jh; pre_jl=jl;
			}
			else {					/* after BS code */
				if(jh == pre_jh && jl == pre_jl) {	/* make Bold */
					putchar(GS);printf("1weF");	/* bold */
					putchar(jh); putchar(jl);	/* send datas */
					pre_jh=jh; pre_jl=jl;
					pre_bs_f=0;
					putchar(GS);printf("0weF");	/* normal */
				}
				else {					/* not Bold but BS? */
					putchar(BS);			/* send a BS code */
					putchar(jh); putchar(jl);	/* send datas */
					pre_jh=jh; pre_jl=jl;
					pre_bs_f=0;
				}
			}

		} /* end if(sjis_kanji(c) || euc_kanji(c)) */

		else if(c == LF) {			/* UNIX : LF = ESC/Page : CR+LF */
			putchar(CR); putchar(LF);	/* send CR,LF */
		}

		else if(c == BS && bs_f == 0) {		/* BSx1 */
			bs_f=1;				/* skip a BS code */
		}

		else if(c == BS && bs_f == 1) {		/* BSx2 */
			putchar(BS);			/* send a BS code */
			bs_f=0;
			pre_bs_f=1;
		}

		else {

			if(bs_f == 1) {			/* BSx1 */
				putchar(BS);		/* send a BS code */
				bs_f=0;
				pre_bs_f=1;
			}

			if(first_f == 1 || kanji_f == 1){
				putchar(GS);printf("264;1ssF");	/* select 1byte code Font */
				putchar(GS);printf("15wcF");	/* select 15 CPI Font */
				putchar(GS);printf("7.68hpF");	/* select 7.68 Point Font */
				putchar(GS);printf("0tfF");	/* select ROMAN */
				putchar(GS);printf("pmP");	/* set pitch off */
				first_f=0;			/* clear first flag */
				kanji_f=0;			/* set 1byte code flag */
			}

 			if(c == 0xaa || c == 0x8e) {		/* check dec kana code */
	    			c=getchar();
	    		}

			if(pre_bs_f == 0) {			/* not BS(Bold) */
				putchar(c);			/* send a data */
				pre_c=c;
			}
			else {						/* after BS */
				if(c == pre_c) {			/* make bold */
					putchar(GS);printf("1weF");	/* bold */
	    				putchar(c);			/* send datas */
					pre_c=c;
					pre_bs_f=0;
					putchar(GS);printf("0weF");	/* normal */
				}
				else {					/* not bold but BS? */
					putchar(c);			/* send a data on another char */
					pre_c=c;
					pre_bs_f=0;
				}
	    		}

		} /* end else */

	} /* end while */

	putchar(GS);printf("264;1ssF");	/* select 1byte code Font */
	putchar(GS);printf("15wcF");	/* select 15 CPI Font */
	putchar(GS);printf("7.68hpF");	/* select 7.68 Point Font */
	putchar(GS);printf("0tfF");	/* select ROMAN */
	putchar(GS);printf("pmP");	/* set pitch off */
	putchar(GS);printf("0weF");	/* normal weight */

	/* ESC/Page -> ESC/P */
	putchar(GS);printf("1;0pmE");

	/* ESC/P -> ESC/PS */
	putchar(ESC);printf("S");putchar(ESC);
	putchar(ESC);printf("SK");

} /* end of main */
 ------------- $B$3$3$^$G(J -----------------
-- 
$B%;(J$B%$(J$B%3(J$B!<(J$B%((J$B%W(J$B%=(J$B%s(J$B!J(J$B3t(J$B!K(J$B!!(J$B9-(J$B5V(J$B;v(J$B6H(J$B=j(J$B!!(J$B#T(J$B#P(J$B@_(J$B7W(J
$BD9(J$BLn(J$B8)(J$B1v(J$B?,(J$B;T(J$B9-(J$B5V(J$B86(J$B?7(J$BED(J80 0263-52-2552
$B1v(J$B86(J$B!!(J$B?J(J$B!J(J Susumu Shiohara $B!K(J