[comp.sources.misc] CAT troff to LaserJet II filter.

sverre@fesk.UUCP (Sverre Froyen) (10/26/87)

This is a filter that takes CAT troff output as input and generates
commands for an HP LaserJet II printer with a K font-cartridge
installed. It has been tested both under SysV.2.2 and SUN 3.3.

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 1)."
# Contents:  Makefile README awk-width fthB.c fthI.c fthR.c fthS.c heqn
#   htroff troff2lj.c
# Wrapped by sverre@fesk on Fri Oct 23 21:55:54 1987
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"Makefile\"
else
echo shar: Extracting \"Makefile\" \(307 characters\)
sed "s/^X//" >Makefile <<'END_OF_Makefile'
Xall: troff2lj ftR ftI ftB ftS
X
Xtroff2lj: troff2lj.c
X	cc -O -o troff2lj troff2lj.c
X
XftR: fthR.c
X	cc -c fthR.c
X	mv fthR.o ftR
X	chmod 755 ftR
XftI: fthI.c
X	cc -c fthI.c
X	mv fthI.o ftI
X	chmod 755 ftI
XftB: fthB.c
X	cc -c fthB.c
X	mv fthB.o ftB
X	chmod 755 ftB
XftS: fthS.c
X	cc -c fthS.c
X	mv fthS.o ftS
X	chmod 755 ftS
END_OF_Makefile
if test 307 -ne `wc -c <Makefile`; then
    echo shar: \"Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f README -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"README\"
else
echo shar: Extracting \"README\" \(2686 characters\)
sed "s/^X//" >README <<'END_OF_README'
XTroff2lj is a filter that translates CAT troff output (as described
Xin the documentation for a SUN work station) into commands for an
XHP LaserJet II laser printer.  The necessary fonts must be present on
Xthe printer, either as a font cartridge or as a downloaded font.
X(The latter has not been tested.)  One obvious improvement would be
Xto have the filter download the fonts as necessary.  At present the
Xprogram is set up to use the K font cartridge.  To use another font,
Xyou will as a minimum need to change the font width tables and
Xprobably also the character translation tables in troff2lj.c.
X
XThe files ftXX.c are the font width tables that should be compiled
Xand placed in `/usr/lib/font/ftXX' for troff to find.  Note that because
Xof a bug in troff, the width tables MUST be named ftR, ftI, ftB, and
XftS.  If two character font names are used (like fthS) troff will not
Xrecognize the special font as being mounted and will also mess up
Xtransitions between roman, italic, and bold sets.  (This was discovered
Xusing troff supplied with a SUN work station running SUN 3.3 Unix).
X
XTroff assumes that the character widths scale with the point size.
XUnfortunately this is not true for several characters on the K font
X(like plus, minus, etc.).  The width tables are set up for 10 point by
Xscaling HP supplied widths by 0.864 and rounding to nearest integer.
XThe widths in fthS.c are likely to contain errors.
X
XThe files heqn and htroff are two scripts that can be used to run
Xeqn and troff with appropriate options and include files.  You probably
Xwant to install troff2lj as the `lpr -t' filter instead of including
Xit in htroff as done here.
X
XHP supplies font width tables on floppy disk for free (you supply
Xthe floppies). They are not copyrighted but they are rather large
Xand therefore not included here. Call your local HP rep.
X
XThe awk script `awk-width' can be used to generate additional troff
Xcharacter width tables from the HP width tables.  Type
X
X	awk -f HP-name > ftXX.c
X
XThe output character table, ftXX.c, must be edited for the width of
Xa space (12).  Position 127 is used for a narrow space (6).  The
Xcharacters `"', `#', `<', `>', `@', `\' `^', `_', `{', `}', and `~'
Xdo not exist on the standard font so the widths of these should be
Xset to zero.  Finally, special characters (on the standard font) must
Xbe added below position 127.  See fthR.c.
X
XThe program has been running for a couple of months and should be
Xreasonably bug free.  Still I should appreciate receiving bug reports
Xas well as any improvements to the program.
X
XEnjoy...
X
XSverre Froyen
XUUCP:   boulder!fesk!sverre, sunpeaks!seri!fesk!sverre
XARPA:   froyen@nmfecc.arpa
XBITNET: froyen@csugold.bitnet
END_OF_README
if test 2686 -ne `wc -c <README`; then
    echo shar: \"README\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f awk-width -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"awk-width\"
else
echo shar: Extracting \"awk-width\" \(317 characters\)
sed "s/^X//" >awk-width <<'END_OF_awk-width'
XBEGIN		{
X			char = 0
X			printf "char xxW [256-32] = {\n"
X		}
X$2 == "POINTS"	{ ps = $1 }
X$1 == "32"	{ char = 1 }
X$1 == "127"	{ char = 0 }
XNF > 0 		{
X			if (char == 1) {
X				width = int ($9 * 8.64 / ps + 0.5)
X				printf "%d,	/* %c */\n", width, $1
X			}
X		}
XEND		{ printf "}	/* from file %s, ps=%f */\n", FILENAME, ps }
END_OF_awk-width
if test 317 -ne `wc -c <awk-width`; then
    echo shar: \"awk-width\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f fthB.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"fthB.c\"
else
echo shar: Extracting \"fthB.c\" \(3519 characters\)
sed "s/^X//" >fthB.c <<'END_OF_fthB.c'
Xchar XXw[256-32] = {
X12,		/* space */
X12,		/* ! */
X0,		/* " */
X0,		/* # */
X21,		/* $ */
X34,		/* % */
X29,		/* & */
X10,		/* ' */
X16,		/* ( */
X16,		/* ) */
X16,		/* * */
X21,		/* + */
X12,		/* , */
X21,		/* - hyphen */
X12,		/* . */
X19,		/* / */
X21+0200,	/* 0 */
X21+0200,	/* 1 */
X21+0200,	/* 2 */
X21+0200,	/* 3 */
X21+0200,	/* 4 */
X21+0200,	/* 5 */
X21+0200,	/* 6 */
X21+0200,	/* 7 */
X21+0200,	/* 8 */
X21+0200,	/* 9 */
X10,		/* : */
X10,		/* ; */
X0,		/* < */
X22,		/* = */
X0,		/* > */
X19,		/* ? */
X0,		/* @ */
X28+0200,	/* A */
X27+0200,	/* B */
X27+0200,	/* C */
X28+0200,	/* D */
X25+0200,	/* E */
X23+0200,	/* F */
X30+0200,	/* G */
X32+0200,	/* H */
X16+0200,	/* I */
X21+0200,	/* J */
X29+0200,	/* K */
X25+0200,	/* L */
X34+0200,	/* M */
X29+0200,	/* N */
X29+0200,	/* O */
X24+0200,	/* P */
X29+0300,	/* Q */
X28+0200,	/* R */
X22+0200,	/* S */
X26+0200,	/* T */
X30+0200,	/* U */
X29+0200,	/* V */
X35+0200,	/* W */
X28+0200,	/* X */
X27+0200,	/* Y */
X28+0200,	/* Z */
X11,		/* [ */
X0,		/* \ */
X12,		/* ] */
X0,		/* ^ */
X0,		/* _ */
X10,		/* ` */
X20,		/* a */
X21+0200,	/* b */
X18,		/* c */
X21+0200,	/* d */
X18,		/* e */
X16+0200,	/* f */
X20+0100,	/* g */
X23+0200,	/* h */
X12+0200,	/* i */
X15+0300,	/* j */
X22+0200,	/* k */
X12+0200,	/* l */
X31,		/* m */
X22,		/* n */
X20,		/* o */
X21+0100,	/* p */
X21+0100,	/* q */
X16,		/* r */
X16,		/* s */
X14+0200,	/* t */
X21,		/* u */
X17,		/* v */
X28,		/* w */
X21,		/* x */
X20+0100,	/* y */
X17,		/* z */
X0,		/* { */
X7,		/* | */
X0,		/* } */
X0,		/* ~ */
X6,		/* narrow space */
X21,		/* hyphen */
X12,		/* bullet */
X22,		/* square */
X31,		/* 3/4 em dash */
X29,		/* rule */
X16,		/* 1/4 */
X16,		/* 1/2 */
X0,		/* 3/4 */
X21,		/* minus */
X0,		/* fi */
X0,		/* fl */
X0,		/* ff */
X0,		/* ffi */
X0,		/* ffl */
X11,		/* degree */
X16,		/* dagger */
X0,		/* section (unimplem) */
X8,		/* foot mark */
X0,		/* acute acc (unimplem) */
X0,		/* grave acc (unimplem) */
X0,		/* underrule (unimplem) */
X0,		/* slash (unimplem) */
X3,		/* half narrow space */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X22,		/* registered */
X22,		/* copyright */
X0,		/* null */
X20,		/* cent */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0		/* null */
X};
END_OF_fthB.c
if test 3519 -ne `wc -c <fthB.c`; then
    echo shar: \"fthB.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f fthI.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"fthI.c\"
else
echo shar: Extracting \"fthI.c\" \(3517 characters\)
sed "s/^X//" >fthI.c <<'END_OF_fthI.c'
Xchar XXw[256-32] = {
X12,		/* space */
X15,		/* ! */
X0,		/* " */
X0,		/* # */
X20,		/* $ */
X28,		/* % */
X28,		/* & */
X9,		/* ' */
X17,		/* ( */
X17,		/* ) */
X18,		/* * */
X20,		/* + */
X10,		/* , */
X20,		/* - hyphen */
X10,		/* . */
X27,		/* / */
X20+0200,	/* 0 */
X20+0200,	/* 1 */
X20+0200,	/* 2 */
X20+0200,	/* 3 */
X20+0200,	/* 4 */
X20+0200,	/* 5 */
X20+0200,	/* 6 */
X20+0200,	/* 7 */
X20+0200,	/* 8 */
X20+0200,	/* 9 */
X16,		/* : */
X15,		/* ; */
X0,		/* < */
X22,		/* = */
X0,		/* > */
X18,		/* ? */
X0,		/* @ */
X26+0200,	/* A */
X25+0200,	/* B */
X27+0200,	/* C */
X29+0200,	/* D */
X25+0200,	/* E */
X25+0200,	/* F */
X26+0200,	/* G */
X30+0200,	/* H */
X16+0200,	/* I */
X21+0200,	/* J */
X27+0200,	/* K */
X26+0200,	/* L */
X35+0200,	/* M */
X29+0200,	/* N */
X29+0200,	/* O */
X24+0200,	/* P */
X29+0300,	/* Q */
X28+0200,	/* R */
X24+0200,	/* S */
X26+0200,	/* T */
X29+0200,	/* U */
X27+0200,	/* V */
X30+0200,	/* W */
X29+0200,	/* X */
X25+0200,	/* Y */
X29+0200,	/* Z */
X21,		/* [ */
X0,		/* \ */
X21,		/* ] */
X0,		/* ^ */
X0,		/* _ */
X9,		/* ` */
X20,		/* a */
X19+0200,	/* b */
X17,		/* c */
X22+0200,	/* d */
X17,		/* e */
X18+0200,	/* f */
X22+0100,	/* g */
X20+0200,	/* h */
X12+0200,	/* i */
X18+0300,	/* j */
X21+0200,	/* k */
X13+0200,	/* l */
X31,		/* m */
X20,		/* n */
X19,		/* o */
X21+0100,	/* p */
X19+0100,	/* q */
X16,		/* r */
X16,		/* s */
X12+0200,	/* t */
X19,		/* u */
X16,		/* v */
X27,		/* w */
X22,		/* x */
X20+0100,	/* y */
X20,		/* z */
X0,		/* { */
X6,		/* | */
X0,		/* } */
X0,		/* ~ */
X6,		/* narrow space */
X20,		/* hyphen */
X12,		/* bullet */
X22,		/* square */
X31,		/* 3/4 em dash */
X29,		/* rule */
X14,		/* 1/4 */
X14,		/* 1/2 */
X0,		/* 3/4 */
X20,		/* minus */
X0,		/* fi */
X0,		/* fl */
X0,		/* ff */
X0,		/* ffi */
X0,		/* ffl */
X14,		/* degree */
X16,		/* dagger */
X0,		/* section (unimplem) */
X8,		/* foot mark */
X0,		/* acute acc (unimplem) */
X0,		/* grave acc (unimplem) */
X0,		/* underrule (unimplem) */
X0,		/* slash (unimplem) */
X3,		/* half narrow space */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X22,		/* registered */
X22,		/* copyright */
X0,		/* null */
X18,		/* cent */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0		/* null */
X};
END_OF_fthI.c
if test 3517 -ne `wc -c <fthI.c`; then
    echo shar: \"fthI.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f fthR.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"fthR.c\"
else
echo shar: Extracting \"fthR.c\" \(3518 characters\)
sed "s/^X//" >fthR.c <<'END_OF_fthR.c'
Xchar XXw[256-32] = {
X12,		/* space */
X10,		/* ! */
X0,		/* " */
X0,		/* # */
X20,		/* $ */
X30,		/* % */
X30,		/* & */
X10,		/* ' */
X13,		/* ( */
X14,		/* ) */
X19,		/* * */
X20,		/* + */
X12,		/* , */
X20,		/* - hyphen */
X10,		/* . */
X18,		/* / */
X20+0200,	/* 0 */
X20+0200,	/* 1 */
X20+0200,	/* 2 */
X20+0200,	/* 3 */
X20+0200,	/* 4 */
X20+0200,	/* 5 */
X20+0200,	/* 6 */
X20+0200,	/* 7 */
X20+0200,	/* 8 */
X20+0200,	/* 9 */
X9,		/* : */
X10,		/* ; */
X0,		/* < */
X22,		/* = */
X0,		/* > */
X19,		/* ? */
X0,		/* @ */
X30+0200,	/* A */
X25+0200,	/* B */
X27+0200,	/* C */
X29+0200,	/* D */
X26+0200,	/* E */
X24+0200,	/* F */
X31+0200,	/* G */
X30+0200,	/* H */
X14+0200,	/* I */
X17+0200,	/* J */
X33+0200,	/* K */
X26+0200,	/* L */
X36+0200,	/* M */
X30+0200,	/* N */
X29+0200,	/* O */
X22+0200,	/* P */
X29+0300,	/* Q */
X29+0200,	/* R */
X19+0200,	/* S */
X26+0200,	/* T */
X32+0200,	/* U */
X29+0200,	/* V */
X33+0200,	/* W */
X31+0200,	/* X */
X29+0200,	/* Y */
X27+0200,	/* Z */
X11,		/* [ */
X0,		/* \ */
X12,		/* ] */
X0,		/* ^ */
X0,		/* _ */
X10,		/* ` */
X18,		/* a */
X22+0200,	/* b */
X18,		/* c */
X22+0200,	/* d */
X18,		/* e */
X16+0200,	/* f */
X20+0100,	/* g */
X22+0200,	/* h */
X12+0200,	/* i */
X15+0300,	/* j */
X22+0200,	/* k */
X11+0200,	/* l */
X32,		/* m */
X22,		/* n */
X20,		/* o */
X22+0100,	/* p */
X21+0100,	/* q */
X16,		/* r */
X15,		/* s */
X13+0200,	/* t */
X22,		/* u */
X21,		/* v */
X29,		/* w */
X21,		/* x */
X21+0100,	/* y */
X17,		/* z */
X0,		/* { */
X7,		/* | */
X0,		/* } */
X0,		/* ~ */
X6,		/* narrow space */
X20,		/* hyphen */
X12,		/* bullet */
X22,		/* square */
X33,		/* 3/4 em dash */
X30,		/* rule */
X18,		/* 1/4 */
X18,		/* 1/2 */
X0,		/* 3/4 */
X20,		/* minus */
X0,		/* fi */
X0,		/* fl */
X0,		/* ff */
X0,		/* ffi */
X0,		/* ffl */
X14,		/* degree */
X16,		/* dagger */
X0,		/* section (unimplem) */
X8,		/* foot mark */
X0,		/* acute acc (unimplem) */
X0,		/* grave acc (unimplem) */
X0,		/* underrule (unimplem) */
X0,		/* slash (unimplem) */
X3,		/* half narrow space */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X22,		/* registered */
X22,		/* copyright */
X0,		/* null */
X21,		/* cent */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0		/* null */
X};
END_OF_fthR.c
if test 3518 -ne `wc -c <fthR.c`; then
    echo shar: \"fthR.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f fthS.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"fthS.c\"
else
echo shar: Extracting \"fthS.c\" \(4114 characters\)
sed "s/^X//" >fthS.c <<'END_OF_fthS.c'
Xchar XXw[256-32] = {
X0,		/* null */
X0,		/* null */
X13,		/* " */
X26,		/* # */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X21,		/* < */
X0,		/* null */
X21,		/* > */
X0,		/* null */
X34,		/* @ */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X18,		/* \ */
X0,		/* null */
X14,		/* ^ */
X30,		/* _ */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X14,		/* { */
X0,		/* null */
X15,		/* } */
X15,		/* ~ */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X20+0300,	/* section */
X0,		/* null */
X10,		/* acute accent */
X10,		/* grave accent */
X30,		/* underrule */
X18,		/* slash (matching backslash) */
X0,		/* null */
X0,		/* null */
X22,		/* alpha */
X21+0300,	/* beta */
X20+0100,	/* gamma */
X16+0200,	/* delta */
X15,		/* epsilon */
X17+0300,	/* zeta */
X19+0100,	/* eta */
X15+0200,	/* theta */
X14,		/* iota */
X20,		/* kappa */
X20+0200,	/* lambda */
X22+0100,	/* mu */
X20,		/* nu */
X18+0300,	/* xi */
X17,		/* omicron */
X20,		/* pi */
X17+0100,	/* rho */
X19,		/* sigma */
X16,		/* tau */
X19,		/* upsilon */
X20+0100,	/* phi */
X22+0100,	/* chi */
X22+0300,	/* psi */
X22,		/* omega */
X21+0200,	/* Gamma */
X30+0200,	/* Delta */
X26+0200,	/* Theta */
X23+0200,	/* Lambda */
X20+0300,	/* Xi */
X26+0200,	/* Pi */
X26+0200,	/* Sigma */
X0,		/* null */
X25+0200,	/* Upsilon */
X26+0200,	/* Phi */
X27+0200,	/* Psi */
X24+0200,	/* Omega */
X30,		/* square root */
X17,		/* terminal sigma */
X30,		/* root en extender */
X21,		/* >= */
X21,		/* <= */
X22,		/* identically equal */
X20,		/* minus */
X26,		/* approx = */
X22,		/* approximates */
X22+0300,	/* not equal */
X34,		/* right arrow */
X34,		/* left arrow */
X18+0200,	/* up arrow */
X18+0200,	/* down arrow */
X22,		/* math equals */
X21,		/* multiply */
X20,		/* divide */
X21,		/* plus-minus */
X24,		/* cup (union) */
X24,		/* cap (intersection) */
X24,		/* subset of */
X24,		/* superset of */
X24,		/* improper subset */
X24,		/* improper superset */
X35,		/* infinity */
X20+0200,	/* partial derivative */
X20,		/* gradient */
X23,		/* not */
X22,		/* integral sign */
X26,		/* proportional to */
X25+0300,	/* empty set */
X24,		/* member of */
X20,		/* math plus */
X0,		/* null */
X0,		/* null */
X30,		/* box vertical rule */
X0,		/* null */
X16+0300,	/* dbl dagger */
X34,		/* right hand */
X34,		/* left hand */
X19+0200,	/* math star */
X21,		/* bell system sign (replaced with h bar)*/
X7+0200,		/* or */
X27,		/* circle */
X30,		/* left top (of big curly) */
X30,		/* left bottom */
X30,		/* right top */
X30,		/* right bot */
X30,		/* left center of big curly bracket */
X30,		/* right center of big curly bracket */
X30,		/* bold vertical */
X30,		/* left floor (lb of bracket) */
X30,		/* right floor (rb of bracket) */
X30,		/* left ceiling (lt of bracket) */
X30,		/* right ceiling (rt of bracket) */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0,		/* null */
X0		/* null */
X};
END_OF_fthS.c
if test 4114 -ne `wc -c <fthS.c`; then
    echo shar: \"fthS.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f heqn -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"heqn\"
else
echo shar: Extracting \"heqn\" \(117 characters\)
sed "s/^X//" >heqn <<'END_OF_heqn'
X#! /bin/sh
X#	invoke eqn with appropriate options for use with
X#	HP LaserJet II and font cartridges.
X#
Xeqn -p2 -fR $*
END_OF_heqn
if test 117 -ne `wc -c <heqn`; then
    echo shar: \"heqn\" unpacked with wrong size!
fi
chmod +x heqn
# end of overwriting check
fi
if test -f htroff -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"htroff\"
else
echo shar: Extracting \"htroff\" \(482 characters\)
sed "s/^X//" >htroff <<'END_OF_htroff'
X#! /bin/sh
X#	invoke troff with appropriate options for use with
X#	HP LaserJet II and font cartridges.
X#
X#	parse arguments
X#
Xoptions=-t
Xfiles=
Xfor i in $*
Xdo case $i in
X	-*) options="$options $i";;
X	*) files="$files $i";;
Xesac
Xdone
X#
X#	insert font files
X#
X(
Xecho "\
X.fp 1 R
X.fp 2 I
X.fp 3 B
X.fp 4 S
X.lg 0"
X#
X#	files string empty -- use standard input
X#
Xif [ "$files" ]
Xthen
X	cat $files
Xelse
X	cat
Xfi
X) | troff $options \
X| /usr/local/lib/troff2lj \
X| uux -n - "sst!/usr/ucb/lpr -Prhp"
END_OF_htroff
if test 482 -ne `wc -c <htroff`; then
    echo shar: \"htroff\" unpacked with wrong size!
fi
chmod +x htroff
# end of overwriting check
fi
if test -f troff2lj.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"troff2lj.c\"
else
echo shar: Extracting \"troff2lj.c\" \(14501 characters\)
sed "s/^X//" >troff2lj.c <<'END_OF_troff2lj.c'
X/*
X *	Filter that translates troff CAT output into commands for
X *	an HP LaserJet II printer with the K font cartridge.
X *	Ideally troff should be used with special width tables,
X *	however, the standard CAT tables produce a readable output.
X *
X *	Note that the K font cartridge only allows point sizes 8 and 10.
X *	A possible fix would be to use the Z font cartridge or to
X *	implement downloadable fonts.
X */
X#include <stdio.h>
X
X/*#define DEBUG				/* Debug option */
X#define COMPRESS			/* Compress text horizontally 5% */
X#define BERKELEY_HACK			/* Codes 0116/0117 are not tilt */
X#define LINES		(11*432)	/* #CAT-lines on a page */
X
X/* Convert CAT units to LaserJet units and set first page offset (CAT units) */
X
X#define SCALE_X(n)	((300*n)/432)
X#ifdef COMPRESS
X# define SCALE_Y(n)	((286.36*n)/432+75)	/* 10.5", 0.25" margin */
X# define SKIP		348			/* Empirical */
X#else
X# define SCALE_Y(n)	((300*n)/432)		/* 11", no margin */
X# define SKIP		240			/* Empirical */
X#endif
X
X/* Some escape codes for LaserJet */
X
X#define INIT		"\033E\033&l0O\033(0U\033(s1p10v0s0b5T"
X#define EXIT		"\033E\033&k2G"
X#define X_POS(x)	"\033*p%dX",x		/* Left to right */
X#define XY_POS(x,y)	"\033*p%dx%dY",x,y	/* Top to bottom */
X#define FORM_FEED	"\033&l1H"
X#define POINT_SIZE(n)	"\033(s%dV",n
X#define ITALIC_OFF	"\033(s0S"
X#define ITALIC_ON	"\033(s1S"
X#define BOLD_OFF	"\033(s0B"
X#define BOLD_ON		"\033(s3B"
X
Xstatic char *prog_name;
X
X/* State of CAT, escape is horizontal motion, lead is vertical motion */
X
Xstatic char upper_rail = 0;
Xstatic char upper_mag = 0;
Xstatic char tilt_up = 0;
Xstatic char upper_font = 0;
Xstatic char escape_backward = 0;
Xstatic char lead_backward = 0;
Xstatic char lead_magnification = 0;
X
X/* These have corresponding LaserJet variables (below) */
X
Xstatic char cat_font = 2;
Xstatic char cat_ps = 10;
Xstatic int cat_col = 0;
Xstatic int cat_row = -SKIP;
X
X/* State of LaserJet */
X
Xstatic char hp_char_set = 0;		/* Values 0 through 5 are allowed */
Xstatic char page_not_blank = 0;		/* Flag */
X
X/* These have corresponding CAT variables (above) */
X
Xstatic char hp_font = 2;
Xstatic char hp_ps = 10;
Xstatic int hp_col = -100000;		/* These are in LaserJet units */
Xstatic int hp_row = -100000;		/* 300 per inch */
X
Xstatic struct char_table {
X	char c;				/* LaserJet character */
X	char char_set;			/* LaserJet character set */
X	char x_shift;			/* Horizontal ajustment */
X	char y_shift;			/* Vertical ajustment */
X};
X
X/*
X *	The next two char_table structures define the mapping of a
X *	CAT character position to the corresponding LaserJet character.
X *	Note the following restrictions in the K font point sizes:
X *
X *	Style				Character Set #
X *			0	1	2	3	4	5
X *	Roman		8,10	8,10	8,10	8,10	10	10
X *	Italic		10	10	*	*	*	*
X *	Bold		10	10	*	*	*	*
X *
X *	The x_shift, y_shift fields are for fine tuning of the final
X *	character position. These will be scaled with the point size
X *	and should be given in units 3000 to the inch for point size 10.
X *	The coordinate directions are:
X *		x_shift: from left to right
X *		y_shift: from top to bottom.
X */
X
Xstatic struct char_table standard_table [110] = {
X	'\0',	0,	0,	0,	/* null */
X	'h',	0,	0,	0,	/* h */
X	't',	0,	0,	0,	/* t */
X	'n',	0,	0,	0,	/* n */
X	'm',	0,	0,	0,	/* m */
X	'l',	0,	0,	0,	/* l */
X	'i',	0,	0,	0,	/* i */
X	'z',	0,	0,	0,	/* z */
X	's',	0,	0,	0,	/* s */
X	'd',	0,	0,	0,	/* d */
X	'b',	0,	0,	0,	/* b */
X	'x',	0,	0,	0,	/* x */
X	'f',	0,	0,	0,	/* f */
X	'j',	0,	0,	0,	/* j */
X	'u',	0,	0,	0,	/* u */
X	'k',	0,	0,	0,	/* k */
X	'\0',	0,	0,	0,	/* null */
X	'p',	0,	0,	0,	/* p */
X	'v',	1,	0,	0,	/* 3/4 em dash */
X	';',	0,	0,	0,	/* ; */
X	'\0',	0,	0,	0,	/* null */
X	'a',	0,	0,	0,	/* a */
X	'_',	0,	0,	-85,	/* rule */
X	'c',	0,	0,	0,	/* c */
X	'`',	0,	0,	0,	/* open quote */
X	'e',	0,	0,	0,	/* e */
X	'\'',	0,	0,	0,	/* close quote */
X	'o',	0,	0,	0,	/* o */
X	'w',	1,	0,	0,	/* 1/4 */
X	'r',	0,	0,	0,	/* r */
X	'x',	1,	0,	0,	/* 1/2 */
X	'v',	0,	0,	0,	/* v */
X	'-',	0,	0,	0,	/* hyphen */
X	'w',	0,	0,	0,	/* w */
X	'q',	0,	0,	0,	/* q */
X	'/',	0,	0,	0,	/* / */
X	'.',	0,	0,	0,	/* . */
X	'g',	0,	0,	0,	/* g */
X	'\0',	0,	0,	0,	/* 3/4 */
X	',',	0,	0,	0,	/* , */
X	'&',	0,	0,	0,	/* & */
X	'y',	0,	0,	0,	/* y */
X	'\0',	0,	0,	0,	/* null */
X	'%',	0,	0,	0,	/* % */
X	'\0',	0,	0,	0,	/* null */
X	'Q',	0,	0,	0,	/* Q */
X	'T',	0,	0,	0,	/* T */
X	'O',	0,	0,	0,	/* O */
X	'H',	0,	0,	0,	/* H */
X	'N',	0,	0,	0,	/* N */
X	'M',	0,	0,	0,	/* M */
X	'L',	0,	0,	0,	/* L */
X	'R',	0,	0,	0,	/* R */
X	'G',	0,	0,	0,	/* G */
X	'I',	0,	0,	0,	/* I */
X	'P',	0,	0,	0,	/* P */
X	'C',	0,	0,	0,	/* C */
X	'V',	0,	0,	0,	/* V */
X	'E',	0,	0,	0,	/* E */
X	'Z',	0,	0,	0,	/* Z */
X	'D',	0,	0,	0,	/* D */
X	'B',	0,	0,	0,	/* B */
X	'S',	0,	0,	0,	/* S */
X	'Y',	0,	0,	0,	/* Y */
X	'\0',	0,	0,	0,	/* null */
X	'F',	0,	0,	0,	/* F */
X	'X',	0,	0,	0,	/* X */
X	'A',	0,	0,	0,	/* A */
X	'W',	0,	0,	0,	/* W */
X	'J',	0,	0,	0,	/* J */
X	'U',	0,	0,	0,	/* U */
X	'K',	0,	0,	0,	/* K */
X	'0',	0,	0,	0,	/* 0 */
X	'1',	0,	0,	0,	/* 1 */
X	'2',	0,	0,	0,	/* 2 */
X	'3',	0,	0,	0,	/* 3 */
X	'4',	0,	0,	0,	/* 4 */
X	'5',	0,	0,	0,	/* 5 */
X	'6',	0,	0,	0,	/* 6 */
X	'7',	0,	0,	0,	/* 7 */
X	'8',	0,	0,	0,	/* 8 */
X	'9',	0,	0,	0,	/* 9 */
X	'*',	0,	0,	0,	/* * */
X	'-',	0,	0,	0,	/* curent font minus */
X	'\0',	0,	0,	0,	/* fi */
X	'\0',	0,	0,	0,	/* fl */
X	'\0',	0,	0,	0,	/* ff */
X	'?',	1,	0,	0,	/* cent sign */
X	'\0',	0,	0,	0,	/* ffl */
X	'\0',	0,	0,	0,	/* ffi */
X	'(',	0,	0,	0,	/* ( */
X	')',	0,	0,	0,	/* ) */
X	'[',	0,	0,	0,	/* [ */
X	']',	0,	0,	0,	/* ] */
X	'3',	1,	0,	0,	/* degree */
X	'N',	3,	0,	0,	/* dagger */
X	'=',	0,	0,	0,	/* = */
X	',',	5,	0,	0,	/* registered */
X	':',	0,	0,	0,	/* : */
X	'+',	0,	0,	0,	/* + */
X	'\0',	0,	0,	0,	/* null */
X	'!',	0,	0,	0,	/* ! */
X	'K',	3,	0,	0,	/* bullet */
X	'?',	0,	0,	0,	/* ? */
X	'\'',	2,	0,	0,	/* foot mark */
X	'|',	0,	0,	0,	/* | */
X	'\0',	0,	0,	0,	/* null */
X	'-',	5,	0,	0,	/* copyright */
X	'l',	5,	0,	0,	/* square */
X	'$',	0,	0,	0	/* $ */
X};
X
Xstatic struct char_table special_table [110] = {
X	'\0',	2,	0,	0,	/* null */
X	'w',	2,	0,	0,	/* psi */
X	'h',	2,	0,	0,	/* theta */
X	'm',	2,	0,	0,	/* nu */
X	'l',	2,	0,	0,	/* mu */
X	'k',	2,	0,	0,	/* lambda */
X	'i',	2,	0,	0,	/* iota */
X	'f',	2,	0,	0,	/* zeta */
X	'r',	2,	0,	0,	/* sigma */
X	'd',	2,	0,	0,	/* delta */
X	'b',	2,	0,	0,	/* beta */
X	'n',	2,	0,	0,	/* xi */
X	'g',	2,	0,	0,	/* eta */
X	'u',	2,	0,	0,	/* phi */
X	't',	2,	0,	0,	/* upsilon */
X	'j',	2,	0,	0,	/* kappa */
X	'\0',	2,	0,	0,	/* null */
X	'p',	2,	0,	0,	/* pi */
X	'@',	0,	0,	0,	/* @ */
X	'#',	3,	0,	0,	/* down arrow */
X	'\0',	2,	0,	0,	/* null */
X	'a',	2,	0,	0,	/* alpha */
X	'|',	0,	0,	0,	/* or */
X	'v',	2,	0,	0,	/* chi */
X	'"',	0,	0,	0,	/* " */
X	'e',	2,	0,	0,	/* epsilon */
X	'=',	2,	0,	0,	/* math equals */
X	'o',	2,	0,	0,	/* omicron */
X	'$',	3,	0,	0,	/* left arrow */
X	'q',	2,	0,	0,	/* rho */
X	'!',	3,	0,	0,	/* up arrow */
X	's',	2,	0,	0,	/* tau */
X	'_',	0,	0,	0,	/* underrule */
X	'\\',	0,	0,	0,	/* \ */
X	'W',	2,	0,	0,	/* Psi */
X	'H',	5,	0,	0,	/* bell system sign */
X	'$',	2,	0,	0,	/* infinity */
X	'c',	2,	0,	0,	/* gamma */
X	'?',	3,	0,	0,	/* improper superset */
X	'&',	2,	0,	0,	/* proportional to */
X	'&',	3,	0,	0,	/* right hand */
X	'x',	2,	0,	0,	/* omega */
X	'\0',	2,	0,	0,	/* null */
X	'Y',	2,	0,	0,	/* gradient */
X	'\0',	2,	0,	0,	/* null */
X	'U',	2,	0,	0,	/* Phi */
X	'H',	2,	0,	0,	/* Theta */
X	'X',	2,	0,	0,	/* Omega */
X	'5',	3,	0,	0,	/* cup (union) */
X	'0',	3,	0,	0,	/* root en extender */
X	'[',	2,	0,	0,	/* terminal sigma */
X	'K',	2,	0,	0,	/* Lambda */
X	'-',	2,	0,	0,	/* math minus */
X	'C',	2,	0,	0,	/* Gamma */
X	'U',	3,	0,	0,	/* integral sign */
X	'P',	2,	0,	0,	/* Pi */
X	':',	3,	0,	0,	/* subset of */
X	';',	3,	0,	0,	/* superset of */
X	'~',	0,	0,	0,	/* approximates */
X	'Z',	2,	0,	0,	/* partial derivative */
X	'D',	2,	0,	0,	/* Delta */
X	'!',	2,	0,	0,	/* square root */
X	'R',	2,	0,	0,	/* Sigma */
X	'?',	2,	0,	0,	/* approx = */
X	'\0',	2,	0,	0,	/* null */
X	'>',	0,	0,	0,	/* > */
X	'N',	2,	0,	0,	/* Xi */
X	'<',	0,	0,	0,	/* < */
X	'/',	0,	0,	0,	/* slash (matching backslash) */
X	'6',	3,	0,	0,	/* cap (intersection) */
X	'T',	2,	0,	0,	/* Upsilon */
X	'H',	3,	0,	0,	/* not */
X	'p',	3,	0,	0,	/* right ceiling */
X	'b',	3,	0,	0,	/* left top */
X	'v',	3,	0,	0,	/* bold vertical (used with floor...) */
X	'c',	3,	0,	0,	/* left center of big curly bracket */
X	'd',	3,	0,	0,	/* left bottom */
X	'r',	3,	0,	0,	/* right top */
X	's',	3,	0,	0,	/* right center of big curly bracket */
X	't',	3,	0,	0,	/* right bottom */
X	'q',	3,	0,	0,	/* right floor */
X	'a',	3,	0,	0,	/* left floor */
X	'`',	3,	0,	0,	/* left ceiling */
X	'*',	2,	0,	0,	/* multiply */
X	'%',	2,	0,	0,	/* divide */
X	'~',	3,	0,	0,	/* plus-minus */
X	'\\',	2,	0,	0,	/* <= */
X	'^',	2,	0,	0,	/* >= */
X	'}',	2,	0,	0,	/* identically equal */
X	']',	2,	0,	0,	/* not equal */
X	'{',	0,	0,	0,	/* { */
X	'}',	0,	0,	0,	/* } */
X	'(',	1,	0,	0,	/* acute accent */
X	')',	1,	0,	0,	/* grave accent */
X	'*',	1,	0,	0,	/* ^ */
X	'#',	0,	0,	0,	/* # */
X	'(',	3,	0,	0,	/* left hand */
X	'7',	3,	0,	0,	/* member of */
X	',',	1,	0,	0,	/* ~ */
X	'X',	3,	0,	0,	/* empty set */
X	'\0',	2,	0,	0,	/* null */
X	'O',	3,	0,	0,	/* double dagger */
X	'v',	3,	0,	0,	/* box vertical rule */
X	'*',	0,	0,	0,	/* math star */
X	'>',	3,	0,	0,	/* improper subset */
X	'M',	3,	0,	0,	/* circle */
X	'\0',	2,	0,	0,	/* null */
X	'+',	2,	0,	0,	/* math plus */
X	'"',	3,	0,	0,	/* right arrow */
X	'=',	1,	0,	0	/* section */
X};
X
Xmain (argc, argv)
Xint argc;
Xchar **argv;
X{
X	prog_name = *argv;
X
X	printf (INIT);
X	read_cat ();
X	printf (EXIT);
X}
X
X/*
X *	Read end interpret CAT codes
X */
X read_cat ()
X {
X	register int c;
X
X	while ((c = getchar ()) != EOF) {
X		if (c & 0200)
X			escape ((~c) & 0177);
X		else if (c < 0100)
X			flash (c);
X		else if ((c & 0340) == 0140)
X			lead ((~c) & 037);
X		else if ((c & 0360) == 0120)
X			change_point_size (c & 017);
X		else if ((c & 0360) == 0100)
X			control (c & 017);
X		else
X			fprintf (stderr, "%s: Illegal CAT code: 0%o\n", prog_name, c);
X	}
X}
X
X/*
X *	Horizontal motion
X */
Xescape (c)
Xint c;
X{
X	if (escape_backward)
X		cat_col -= c;
X	else
X		cat_col += c;
X}
X
X/*
X *	Print character
X */
Xflash (c)
Xint c;
X{
X	if (upper_font)
X		c += 64;
X
X#ifdef DEBUG
X	fprintf (stderr, "Flash char %d on font %d, ", c, cat_font);
X#endif
X
X	if (cat_font <= 7)
X		hp_print_char (standard_table [c]);
X	else
X		hp_print_char (special_table [c]);
X	
X	page_not_blank = 1;
X}
X
X/*
X *	Vertical motion
X */
Xlead (c)
Xint c;
X{
X	if (lead_magnification)
X		c <<= 6;
X	lead_magnification = 0;
X
X	c *= 3;
X
X	if (lead_backward)
X		cat_row -= c;
X	else
X		cat_row += c;
X
X	if (cat_row >= LINES) {
X		hp_form_feed ();
X		cat_row -= LINES;
X	}
X}
X
X/*
X *	Interpret change-point-size code
X */
Xchange_point_size (c)
Xint c;
X{
X	static int c_last = 2;
X	static char point_size_table [15] =
X		{7, 8, 10, 11, 12, 14, 18, 9, 6, 16, 20, 22, 24, 28, 36};
X
X	/* Adjust escape */
X
X	if (c_last <= 8 && c > 8)		/* Single to double */
X		cat_col -= 55;
X	else if (c_last > 8 && c <= 8)		/* Double to single */
X		cat_col += 55;
X	c_last = c;
X	
X	/* Interpret new point size */
X
X	if (c >= 0 && c <= 016)
X		cat_ps = point_size_table [c];
X	else
X		fprintf (stderr, "%s: Illegal CAT point size: 0%o\n", prog_name, c);
X
X	if (hp_ps != cat_ps)
X		hp_change_point_size ();
X
X#ifdef DEBUG
X	fprintf (stderr, "New point_size %d\n", cat_ps);
X#endif
X}
X
X/*
X *	CAT control codes: init and font changes
X */
Xcontrol (c)
Xint c;
X{
X	switch (c) {
X	case 0:				/* Initialize */
X		upper_rail = 0;
X		upper_mag = 0;
X		tilt_up = 0;
X		upper_font = 0;
X		escape_backward = 0;
X		lead_backward = 0;
X		lead_magnification = 0;
X		break;
X	case 01:			/* Font change */
X		upper_rail = 0;
X		break;
X	case 02:			/* Font change */
X		upper_rail = 1;
X		break;
X	case 03:			/* Font change */
X		upper_mag = 1;
X		break;
X	case 04:			/* Font change */
X		upper_mag = 0;
X		break;
X	case 05:			/* Change font half */
X		upper_font = 0;
X		break;
X	case 06:			/* Change font half */
X		upper_font = 1;
X		break;
X	case 07:			/* Change horizontal direction */
X		escape_backward = 0;
X		break;
X	case 010:			/* Change horizontal direction */
X		escape_backward = 1;
X		break;
X	case 011:			/* Stop code */
X		break;
X	case 012:			/* Change vertical direction */
X		lead_backward = 0;
X		break;
X	case 014:			/* Change vertical direction */
X		lead_backward = 1;
X		break;
X#ifdef BERKELEY_HACK
X	case 016:			/* Magnify next lead 64 times */
X		lead_magnification = 1;
X		break;
X#else
X	case 016:			/* Font change */
X		tilt_up = 1;
X		break;
X	case 017:			/* Font change */
X		tilt_up = 0;
X		break;
X#endif
X	default:
X		fprintf (stderr, "%s: Illegal CAT control code: 0%o\n", prog_name, c);
X		break;
X	}
X
X	cat_font = 2 - tilt_up + (upper_rail << 1) + (upper_mag << 2);
X
X	if (hp_font != cat_font)
X		hp_change_font ();
X
X#ifdef DEBUG
X	fprintf (stderr, "Control code: 0%o\n", c);
X#endif
X}
X
Xhp_print_char (c)
Xstruct char_table c;
X{
X	int x, y;
X
X	if (hp_char_set != c.char_set)
X		hp_change_char_set (c.char_set);
X
X	/* Convert to LaserJet coordinates (50 is for rounding) */
X
X	if (c.x_shift < 0)
X		x = SCALE_X(cat_col) + (c.x_shift * hp_ps - 50) / 100;
X	else
X		x = SCALE_X(cat_col) + (c.x_shift * hp_ps + 50) / 100;
X	if (c.y_shift < 0)
X		y = SCALE_Y(cat_row) + (c.y_shift * hp_ps - 50) / 100;
X	else
X		y = SCALE_Y(cat_row) + (c.y_shift * hp_ps + 50) / 100;
X
X	/* Position LaserJet (cannot trust hp_col -- see below) */
X
X	if (hp_row != y)
X		printf (XY_POS(x,y));
X	else
X		printf (X_POS(x));
X
X	putchar (c.c);
X
X	hp_col = x;			/* Wrong by a character width */
X	hp_row = y;
X
X#ifdef DEBUG
X	fprintf (stderr, "col=%d, row=%d, ", x, y);
X	fprintf (stderr, "hp_c = %c(%d), c_set=%d\n", c.c, c.c, c.char_set);
X#endif
X}
X
Xhp_change_char_set (char_set)
Xchar char_set;
X{
X	switch (char_set) {
X	case 0:				/* USASCII */
X		printf ("\033(0U");
X		break;
X	case 1:				/* Roman Extension */
X		printf ("\033(0E");
X		break;
X	case 2:				/* Math 8a */
X		printf ("\033(0Q");
X		break;
X	case 3:				/* Math 8b */
X		printf ("\033(1Q");
X		break;
X	case 4:				/* Math 7 */
X		printf ("\033(0A");
X		break;
X	case 5:				/* PiFonta */
X		printf ("\033(2Q");
X		break;
X	default:
X		fprintf (stderr, "%s: Illegal HP character set: %d\n", prog_name, char_set);
X		break;
X	}
X	hp_char_set = char_set;
X}
X
Xhp_form_feed ()
X{
X	if (page_not_blank)
X		printf (FORM_FEED);
X
X	page_not_blank = 0;
X}
X
Xhp_change_point_size ()
X{
X
X/*
X *	Note that no checking is done to see if the asked for
X *	point size is available.
X */
X
X	printf (POINT_SIZE(cat_ps));
X	
X	hp_ps = cat_ps;
X}
X
Xhp_change_font ()
X{
X	switch (cat_font) {
X	case 1:				/* Standard */
X	case 2:
X	case 7:
X	case 8:
X		printf (BOLD_OFF);
X		printf (ITALIC_OFF);
X		break;
X	case 3:				/* Italic */
X	case 4:
X		printf (BOLD_OFF);
X		printf (ITALIC_ON);
X		break;
X	case 5:				/* Bold */
X	case 6:
X		printf (BOLD_ON);
X		printf (ITALIC_OFF);
X		break;
X	default:
X		fprintf (stderr, "%s: Illegal HP font: %d\n", prog_name, cat_font);
X		break;
X	}
X	
X	hp_font = cat_font;
X}
END_OF_troff2lj.c
if test 14501 -ne `wc -c <troff2lj.c`; then
    echo shar: \"troff2lj.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 1 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Sverre Froyen
UUCP:   boulder!fesk!sverre, sunpeaks!seri!fesk!sverre
ARPA:   froyen@nmfecc.arpa
BITNET: froyen@csugold.bitnet