LaserJet "driver" for N/TROFF

Kean Johnston kean at pscnet.UUCP
Fri Nov 23 06:33:16 AEST 1990


Hello all.
I thought this little bit of information might help anyone who has ever
wanted to print out MAN pages to an HP LaserJet, and is sick and tired
of things going wrong, no italics, propper bolding etc.

I have never seen an man macros that will format output for a LaserJet,
so I took a rather sneaky path to a solution:

When you use either NROFF or TROFF, you can specify, via the -T option,
what terminal you wish the output to be formatted for. The files which
are used when you use the -T option are found in /usr/lib/term.

Below is a C file for a LaserJet "terminal" which you can pass to either
NROFF or TROFF. The file is called tabljet.c. Put this file in /usr/lib/term
and do the following:

cc -O -c -M0 tabljet.c
cc -o mkterm -M0 mkterm.o tabljet.o

This will create an executable "mkterm". Run this program, and it will
create a file called "tabljet". This contains all the necessary escape
sequences for propper bolding, italics etc. I use it all the time now
for printing man pages on the LaserJet. To format output for the laser
just type in nroff -man -Tljet filename | tbl > outfile.

This will format file filename using all the escape sequences, and send
it to the file outfile. Just print this file and your man pages look
quite spectacular.

I hope this helps and is of some use to you all.

Oh, BTW, this was done for Xenix/386, and you need the development system.
I'm not sure if this scheme of getting terminal info from /usr/lib/term
applies to other flavours of Unix, but it might.

tabljet.c starts here:
/*
 *	tabljet.c 21 November 1990
 *
 *  "terminal" driver for HP LaserJet (HP2686) for {n|t}roff
 */

#include <stdio.h>
#include "terms.h"
#define INCH 240

/*
Line Printer with col-only reverse line feed
nroff driving tables
width and code tables
*/

struct termtable tljet = {
/*bset*/	0,
/*breset*/	0,
/*Hor*/		INCH/10,
/*Vert*/	INCH/6,
/*Newline*/	INCH/6,
/*Char*/	INCH/10,
/*Em*/		INCH/10,
/*Halfline*/	INCH/12,
/*Adj*/		INCH/10,
/*twinit*/	"\033E\033&a5L\033&a85M\033&l68P\033&l2E\033&l66F",
/*twrest*/	"\033E",
/*twnl*/	"\n\r",
/*hlr*/		"",
/*hlf*/		"\033=",
/*flr*/		"\033&a-1R",
/*bdon*/	"\033(s3B\033)s3B",
/*bdoff*/	"\033(s-3B\033)s-3B",
/*iton*/	"\033(s3B\033)s3B\033(s1S\033)s1S",
/*itoff*/	"\033(s-3B\033)s-3B\033(s0S\033)s0S",
/*ploton*/	"",
/*plotoff*/	"",
/*up*/		"",
/*down*/	"",
/*right*/	"",
/*left*/	"",
/*codetab*/
"\001 ",	/*space*/
"\001!",	/*!*/
"\001\"",	/*"*/
"\001#",	/*#*/
"\001$",	/*$*/
"\001%",	/*%*/
"\001&",	/*&*/
"\001'",	/*' close*/
"\001(",	/*(*/
"\001)",	/*)*/
"\001*",	/***/
"\001+",	/*+*/
"\001,",	/*,*/
"\001-",	/*- hyphen*/
"\001.",	/*.*/
"\001/",	/*/*/
"\201\060",	/*0*/
"\201\061",	/*1*/
"\201\062",	/*2*/
"\201\063",	/*3*/
"\201\064",	/*4*/
"\201\065",	/*5*/
"\201\066",	/*6*/
"\201\067",	/*7*/
"\201\070",	/*8*/
"\201\071",	/*9*/
"\001:",	/*:*/
"\001;",	/*;*/
"\001<",	/*<*/
"\001=",	/*=*/
"\001>",	/*>*/
"\001?",	/*?*/
"\001@",	/*@*/
"\201A",	/*A*/
"\201B",	/*B*/
"\201C",	/*C*/
"\201D",	/*D*/
"\201E",	/*E*/
"\201F",	/*F*/
"\201G",	/*G*/
"\201H",	/*H*/
"\201I",	/*I*/
"\201J",	/*J*/
"\201K",	/*K*/
"\201\114",	/*L*/
"\201M",	/*M*/
"\201N",	/*N*/
"\201O",	/*O*/
"\201P",	/*P*/
"\201Q",	/*Q*/
"\201R",	/*R*/
"\201S",	/*S*/
"\201T",	/*T*/
"\201U",	/*U*/
"\201V",	/*V*/
"\201W",	/*W*/
"\201X",	/*X*/
"\201Y",	/*Y*/
"\201Z",	/*Z*/
"\001[",	/*[*/
"\001\\",	/*\*/
"\001]",	/*]*/
"\001^",	/*^*/
"\001_",	/*_ dash*/
"\001`",	/*` open*/
"\201a",	/*a*/
"\201b",	/*b*/
"\201c",	/*c*/
"\201d",	/*d*/
"\201e",	/*e*/
"\201f",	/*f*/
"\201g",	/*g*/
"\201h",	/*h*/
"\201i",	/*i*/
"\201j",	/*j*/
"\201k",	/*k*/
"\201\154",	/*l*/
"\201m",	/*m*/
"\201n",	/*n*/
"\201o",	/*o*/
"\201p",	/*p*/
"\201q",	/*q*/
"\201r",	/*r*/
"\201s",	/*s*/
"\201t",	/*t*/
"\201u",	/*u*/
"\201v",	/*v*/
"\201w",	/*w*/
"\201x",	/*x*/
"\201y",	/*y*/
"\201z",	/*z*/
"\001{",	/*{*/
"\001|",	/*|*/
"\001}",	/*}*/
"\001~",	/*~*/
"\000\0",	/*nar sp*/
"\001-",	/*hyphen*/
"\001\374",	/*bullet*/
"\002\[]",	/*square*/
"\001-",	/*3/4 em*/
"\001_",	/*rule*/
"\001\254",	/*1/4*/
"\001\253",	/*1/2*/
"\001\063/4",	/*3/4*/
"\001-",	/*minus*/
"\202fi",	/*fi*/
"\202fl",	/*fl*/
"\202ff",	/*ff*/
"\203ffi",	/*ffi*/
"\203ffl",	/*ffl*/
"\001\370",/*degree*/
"\001|\b-",	/*dagger*/
"\000\0",	/*section*/
"\001'",	/*foot mark*/
"\001'",	/*acute accent*/
"\001`",	/*grave accent*/
"\001_",	/*underrule*/
"\001/",	/*slash (longer)*/
"\000\0",	/*half narrow space*/
"\001 ",	/*unpaddable space*/
"\001\340",		/*alpha*/
"\001\341",		/*beta*/
"\001\342",		/*gamma*/
"\001\353",		/*delta*/
"\001\356",		/*epsilon*/
"\001\345",		/*zeta*/
"\000",		/*eta*/
"\000",		/*theta*/
"\201i",	/*iota*/
"\201k",	/*kappa*/
"\000",		/*lambda*/
"\001\346",		/*mu*/
"\000",		/*nu*/
"\000",		/*xi*/
"\201o",	/*omicron*/
"\001\343",		/*pi*/
"\000",		/*rho*/
"\001\345",		/*sigma*/
"\001347",		/*tau*/
"\201v",	/*upsilon*/
"\000",		/*phi*/
"\201x",	/*chi*/
"\000",		/*psi*/
"\000",		/*omega*/
"\000",		/*Gamma*/
"\000",		/*Delta*/
"\001\351",		/*Theta*/
"\000",		/*Lambda*/
"\000\0",	/*Xi*/
"\000",		/*Pi*/
"\001\344",		/*Sigma*/
"\000\0",	/**/
"\201Y",	/*Upsilon*/
"\001\350",		/*Phi*/
"\000",		/*Psi*/
"\001\352",		/*Omega*/
"\000\0",	/*square root*/
"\000\0",	/*terminal sigma*/
"\000\0",	/*root en*/
"\001>\b_",	/*>=*/
"\001<\b_",	/*<=*/
"\001=\b_",	/*identically equal*/
"\001-",	/*equation minus*/
"\001=\b~",	/*approx =*/
"\000\0",	/*approximates*/
"\001=\b/",	/*not equal*/
"\002->",	/*right arrow*/
"\002<-",	/*left arrow*/
"\001|\b^",	/*up arrow*/
"\001|\bv",	/*down arrow*/
"\001=",	/*equation equal*/
"\001x",	/*multiply*/
"\001/",	/*divide*/
"\001+\b_",	/*plus-minus*/
"\001U",	/*cup (union)*/
"\001\357",	/*cap (intersection)*/
"\000\0",	/*subset of*/
"\000\0",	/*superset of*/
"\000\0",	/*improper subset*/
"\000\0",	/*improper superset*/
"\001\354",	/*infinity*/
"\000",		/*partial derivative*/
"\000",		/*gradient*/
"\000",		/*not*/
"\000",		/*integral sign*/
"\000\0",	/*proportional to*/
"\000\0",	/*empty set*/
"\000\0",	/*member of*/
"\001+",	/*equation plus*/
"\001r\bO",	/*registered*/
"\001c\bO",	/*copyright*/
"\001|",	/*box rule*/
"\001c\b/",	/*cent sign*/
"\001|\b=",	/*dbl dagger*/
"\002=>",	/*right hand*/
"\002<=",	/*left hand*/
"\001*",	/*math * */
"\000\0",	/*bell system sign*/
"\001|",	/*or (was star)*/
"\001O",	/*circle*/
"\001|",	/*left top (of big curly)*/
"\001|",	/*left bottom*/
"\001|",	/*right top*/
"\001|",	/*right bot*/
"\001|",	/*left center of big curly bracket*/
"\001|",	/*right center of big curly bracket*/
"\001|",	/*bold vertical*/
"\001|",	/*left floor (left bot of big sq bract)*/
"\001|",	/*right floor (rb of ")*/
"\001|",	/*left ceiling (lt of ")*/
"\001|"};	/*right ceiling (rt of ")*/


/*
 * To create your own driving table:
 *
 * - Modify the above definitions for your printer. See term(F) for details.
 * - Change `tabuser' below to reflect the name of your printer.
 * - Change `tuser' below to reflect the name of the structure above.
 * - Execute `make' to link this file with maketerms.o and execute it to
 * - create your table.
 * - Install in /usr/lib/term
 */

userterms()
{
	mkterm("tabljet", &tljet);
}

tabljet.c ends here

-- 
+----------------------------------------------------------------------------+
| Kean Johnston: ..!ddsw1!olsa99!tabbs!kean                 kean at pscnet.UUCP |
|                "I drink, therefore I AM" - Dene Rescartes                  |
+----------------------------------------------------------------------------+



More information about the Comp.unix.xenix.sco mailing list