edf@ROCKEFELLER.ARPA (David MacKenzie) (07/28/88)
Posting-number: Volume 4, Issue 5 Submitted-by: "David MacKenzie" <edf@ROCKEFELLER.ARPA> Archive-name: troff2lj-v2/Part1 Troff2lj This is a revision of the C/A/T to LaserJet troff postprocessor posted by Sverre Fesk (comp.sources.misc archive name 871026.0) that adds support for LaserJet soft fonts, and contains a few related utility programs. #! /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 2)." # Contents: README README2 MANIFEST Makefile sfp.pic ccfinfo.1 # ccfont.1 dewidth.1 download.1 dumpfont.1 hpwidth.1 installfont.1 # htroff.1 mkhpfi.1 troff2lj.1 width.1 hpfont.5 hpfontinfo.5 # hpconfig.h hpfinfo.h hpfont.h dewidth.c download.c dumpfont.c # hpwidth.c mkhpfi.c select.c ccfinfo # Wrapped by dave@edfdc on Wed Jul 27 23:15:11 1988 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(1766 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' XTroff2lj is a filter that translates CAT troff output (as described in Xthe documentation for a SUN work station) into commands for an HP XLaserJet laser printer. The necessary fonts must be present on the Xprinter, either as a font cartridge or as a downloaded font. One Xobvious improvement would be to have the filter download the fonts as Xnecessary. X XThe files fthX.c are the font width tables for the K font cartridge Xthat should be compiled and placed in `/usr/lib/font/ftX' for troff to Xfind. X XThe special font MUST be called ftS. This is necessary because of Xa bug in troff (at least under SUN 3.0-3.2). This by the way was a Xfatal bug, if you tried to call it something else it would still Xuse ftS. The other tables appears to work when you rename them. XInitially I called them fth[RIB] and it appeared to work just fine. XThen I started to notice that sometimes troff would use the wrong font. XAfter hours of debugging I finally noticed that everything worked Xjust fine when I changed the file names. 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 XYou probably want to install troff2lj as the `lpr -t' filter instead of Xincluding it in htroff as done here. 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_FILE if test 1766 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'README2' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README2'\" else echo shar: Extracting \"'README2'\" \(3058 characters\) sed "s/^X//" >'README2' <<'END_OF_FILE' XREADME2 for troff2lj X XJuly 27, 1988 X XThis package contains my extensions to Sverre's program for using Xarbitrary LaserJet soft fonts. Programs to download LaserJet soft Xfonts to the printer (download), to install LaserJet fonts as troff Xfonts (installfont), and to analyze LaserJet soft fonts (dumpfont) are Xalso provided. X XInstallation X XA new directory must be made to hold troff2lj configuration files, one Xfor each font except the special font (font S). The default name for Xthat directory is /usr/lib/hpfontinfo. You can change it by editing Xhpconfig.h and installfont.sh. X XYou may have to edit the typedefs in hpconfig.h. Also, compile with XLOHI defined if your machine stores integers low byte first (like a XVAX, unlike a 680x0). X XIn order for dewidth and ccfinfo to operate correctly, the size of the Xobject file headers on your system must be set correctly. By default, Xthe size of the struct exec defined in <a.out.h> is used. If Xnecessary, you can define HDRBYTES manually when compiling dewidth.c. X XWatch out for soft fonts that have a null entry in the "symbol set" Xfield of their font descriptor; troff2lj expects soft fonts to use the XUSASCII symbol set. Use dumpfont to check this out, and if necessary, Xuse a binary file editor to change the value of that byte to a 21 decimal X(the encoded form of "0U", the selector for USASCII). X XYou might have problems using the Courier and Line Printer typefaces Xwhich are built into the LaserJets, particularly if (like me) you have Xan Elite font cartridge installed. I think this is because troff2lj is Xset up for proportionally spaced fonts, and thus ignores pitch Xselection. You could use the standard troff /usr/lib/font/ftCW file as Xthe width table and make fiXX (HPfontinfo) files by hand, but because Xof the order that font attributes are checked to determine font Xselection, you might get the wrong font. If you have problems, you Xcould use nroff instead. X XComments On Macro Packages X XYou'll need to grep through your macro packages and change any ".lg" Xstatements to ".lg 0", since the LaserJet fonts don't contain Xligatures. I was missing "ff"'s and "fi"'s in my manual page printouts Xuntil I discovered a ".lg" statement in my -man macros. X XAlso, I suggest that you go through your macro packages and remove the Xinstructions that put in the typesetter cut marks, since they show up on Xthe LaserJet as an ugly dash in the corner of the page. Usually you Xwill need to edit a ".tl" command to remove either "--" (as in the -ms Xmacros) or "\l..." (as in the -man macros). Just replace them with null Xarguments. X XIf for some reason you want to print out manual pages in a font that Xyou don't have in 10 point, you can set the -man macros' number Xregisters to select a different font size. For example, to use 18 Xpoint type (with 20 point vertical spacing), put at the top of the Xtroff source file: X X.nr )S 18 X.nr )V 20 X XCheck the MANIFEST for a full listing of the included files. X XDavid MacKenzie XEnvironmental Defense Fund Xedf@rocky2.rockefeller.edu (...rutgers!cmcl2!rocky2!edf). END_OF_FILE if test 3058 -ne `wc -c <'README2'`; then echo shar: \"'README2'\" unpacked with wrong size! fi # end of 'README2' fi if test -f 'MANIFEST' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'MANIFEST'\" else echo shar: Extracting \"'MANIFEST'\" \(2275 characters\) sed "s/^X//" >'MANIFEST' <<'END_OF_FILE' X File Name Archive # Description X----------------------------------------------------------- X README 1 Summary of troff2lj X README2 1 Summary of new features X MANIFEST 1 This shipping list X Makefile 1 Data for "make" program X sfp.pic 1 Picture of .sfp format X ccfinfo.1 1 Documentation X ccfont.1 1 Documentation X dewidth.1 1 Documentation X download.1 1 Documentation X dumpfont.1 1 Documentation X hpwidth.1 1 Documentation X installfont.1 1 Documentation X htroff.1 1 Documentation X mkhpfi.1 1 Documentation X troff2lj.1 1 Documentation X width.1 1 Documentation X hpfont.5 1 Documentation X hpfontinfo.5 1 Documentation X hpconfig.h 1 Path and fiXX and .sfp portability definitions X hpfinfo.h 1 fiXX structure definitions X hpfont.h 1 .sfp structure definitions X dewidth.c 1 ftXX -> .c X download.c 1 Download .sfp to printer X dumpfont.c 1 Display .sfp in ASCII form X hpwidth.c 1 .sfp -> .c X mkhpfi.c 1 .sfp -> fiXX X select.c 1 Part of CAT -> LaserJet X troff2lj.c 2 Most of CAT -> LaserJet X ccfinfo 1 .c -> fiXX X ccfont 2 .c -> ftXX X heqn 2 Eqn front end for LaserJet X htroff 2 Troff front end for LaserJet X installfont 2 Install LaserJet font for troff X width 2 HP ASCII file -> .c X fthR.c 2 Troff font source code (K font cartridge) X fthI.c 2 Troff font source code (K font cartridge) X fthB.c 2 Troff font source code (K font cartridge) X fthS.c 2 Troff font source code (K font cartridge) X fiR.c 2 Troff2lj HPfontinfo source code (K cart) X fiI.c 2 Troff2lj HPfontinfo source code (K cart) X fiB.c 2 Troff2lj HPfontinfo source code (K cart) END_OF_FILE if test 2275 -ne `wc -c <'MANIFEST'`; then echo shar: \"'MANIFEST'\" unpacked with wrong size! fi # end of 'MANIFEST' fi if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(1686 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' X# Makefile for troff2lj X# Latest revision: 07/27/88 X X# There's no "install" target, because that will vary too much from site X# to site and needs some manual intervention anyway. X X# CFLAGS might include -DLOHI; see README2. XCFLAGS = -O X XDOCS = README README2 Makefile sfp.pic X XMANS = \ Xdewidth.1 download.1 dumpfont.1 hpwidth.1 \ Xinstallfont.1 htroff.1 mkhpfi.1 ccfinfo.1 ccfont.1 troff2lj.1 width.1 \ Xhpfont.5 hpfontinfo.5 X XHDRS = hpconfig.h hpfinfo.h hpfont.h X XSRCS = \ Xdewidth.c download.c dumpfont.c hpwidth.c mkhpfi.c select.c troff2lj.c \ Xheqn htroff installfont ccfinfo ccfont width \ XfthR.c fthI.c fthB.c fthS.c fiR.c fiI.c fiB.c X XPGMS = \ Xdewidth download dumpfont hpwidth mkhpfi troff2lj X XFONT = fthR fthI fthB fthS fiR fiI fiB X Xall: $(PGMS) $(FONT) X Xdewidth: dewidth.c X $(CC) $(CFLAGS) dewidth.c -o dewidth X strip dewidth X Xdownload: download.c X $(CC) $(CFLAGS) download.c -o download X strip download X Xdumpfont: dumpfont.c X $(CC) $(CFLAGS) dumpfont.c -o dumpfont X strip dumpfont X Xhpwidth: hpwidth.c X $(CC) $(CFLAGS) hpwidth.c -o hpwidth X strip hpwidth X Xmkhpfi: mkhpfi.c X $(CC) $(CFLAGS) mkhpfi.c -o mkhpfi X strip mkhpfi X Xtroff2lj: troff2lj.o select.o X $(CC) -o troff2lj troff2lj.o select.o X strip troff2lj X X# Font width files. XfthR: fthR.c X ccfont fthR X XfthI: fthI.c X ccfont fthI X XfthB: fthB.c X ccfont fthB X XfthS: fthS.c X ccfont fthS X X# HP fontinfo files. XfiR: fiR.c X ccfinfo fiR X XfiI: fiI.c X ccfinfo fiI X XfiB: fiB.c X ccfinfo fiB X Xclean: X rm -f $(PGMS) $(FONT) *.o kit Part* core X X# makekit is part of Rich $alz's cshar package. Xkit: $(DOCS) $(MANS) $(HDRS) $(SRCS) X makekit -m -p X touch kit X X# Add missing default rule for UNOS. X.SUFFIXES: .o X.c.o: X $(CC) $(CFLAGS) -c $< END_OF_FILE if test 1686 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'sfp.pic' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'sfp.pic'\" else echo shar: Extracting \"'sfp.pic'\" \(1462 characters\) sed "s/^X//" >'sfp.pic' <<'END_OF_FILE' X............................................................^ ^ a=f_cheight X............................................................| | b=c_height X...++++++***********************++++++*****.................|^|^c=f_baseline X...++******************************++****++.................||||d=c_topoff X...******++++++++++++++++++++++********++++.................abcd X...*****++++++++++++++++++++++++******+++++.................|||| X...+****+++++++++++++++++++++++++*****+++++.................|||| X...++****+++++++++++++++++++++++*****++++++.................|||| X...+++*******************************++++++.................||vv X...+++++**************************+++++++++.................||-baseline- X...+++++++++++++++++++*****++++++++++++++++.................|| X...++++++++++++++++++++*****+++++++++++++++.................||-underline- X...+++++++++++++++++++++****+++++++++++++++.................||-(top=base- X...++++++++++++++++++++*****+++++++++++++++.................||-line - 5)- X...+++++++++++++++++******+++++++++++++++++.................|| X...++++*****++++++******+++++++++++++++++++.................|| X...+++++*************++++++++++++++++++++++.................|| X...+++++++********+++++++++++++++++++++++++.................|v X............................................................v X<------------------------f_cwidth--------------------------> X<---------------c_delta_x------------------> X<e><---------------c_width----------------> Xe=c_leftoff END_OF_FILE if test 1462 -ne `wc -c <'sfp.pic'`; then echo shar: \"'sfp.pic'\" unpacked with wrong size! fi # end of 'sfp.pic' fi if test -f 'ccfinfo.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ccfinfo.1'\" else echo shar: Extracting \"'ccfinfo.1'\" \(383 characters\) sed "s/^X//" >'ccfinfo.1' <<'END_OF_FILE' X.TH CCFINFO 1 X.SH NAME Xccfinfo \- make troff font from C source code X.SH SYNOPSIS X.B ccfinfo fontname... X.SH DESCRIPTION X.I Ccfinfo Xcompiles source code produced by hand into a troff2lj Xhpfontinfo file. Its arguments should be given without extensions, e.g. to Xproduce fiH from fiH.c, give the command X.sp X.RS X.I ccfinfo fiH. X.RE X.SH "SEE ALSO" Xccfont(1) X.SH AUTHOR XDavid MacKenzie END_OF_FILE if test 383 -ne `wc -c <'ccfinfo.1'`; then echo shar: \"'ccfinfo.1'\" unpacked with wrong size! fi # end of 'ccfinfo.1' fi if test -f 'ccfont.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ccfont.1'\" else echo shar: Extracting \"'ccfont.1'\" \(429 characters\) sed "s/^X//" >'ccfont.1' <<'END_OF_FILE' X.TH CCFONT 1 X.SH NAME Xccfont \- make troff font from C source code X.SH SYNOPSIS X.B ccfont fontname... X.SH DESCRIPTION X.I Ccfont Xcompiles source code produced by hpwidth(1) or width(1) into a troff Xwidth file. Its arguments should be given without extensions, e.g. to Xproduce ftH from ftH.c, give the command X.sp 1 X.RS X.I ccfont ftH. X.RE X.SH "SEE ALSO" Xccfinfo(1), hpwidth(1), width(1) X.SH AUTHORS XSverre Froyen, David MacKenzie END_OF_FILE if test 429 -ne `wc -c <'ccfont.1'`; then echo shar: \"'ccfont.1'\" unpacked with wrong size! fi # end of 'ccfont.1' fi if test -f 'dewidth.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'dewidth.1'\" else echo shar: Extracting \"'dewidth.1'\" \(871 characters\) sed "s/^X//" >'dewidth.1' <<'END_OF_FILE' X.TH DEWIDTH 1 X.SH NAME Xdewidth \- decode troff width file to C source X.SH SYNOPSIS X.B dewidth X[ X.B \-h X] X.B ftfile... X.SH DESCRIPTION X.I Dewidth Xoutputs the contents of troff(1) font width files (such as /usr/lib/font/ft*) Xas source code for C character arrays which, when compiled, will produce a Xfile that is identical to the original. The character which each width in Xthe array corresponds to is shown as a C comment. X.PP XSome of the entries have values with 0100, 0200, or 0300 (octal) added; these Xflags mean that the character extends below the small a, above the small a, or Xboth. They are used to determine such things as where to place a bar Xover a character. X.PP XIf run with the X.I \-h Xoption, X.I dewidth Xwrites to the standard output Xthe size of object file header that it is configured for, and exits. X.SH "SEE ALSO" Xhpwidth(1) X.SH AUTHOR XDavid MacKenzie END_OF_FILE if test 871 -ne `wc -c <'dewidth.1'`; then echo shar: \"'dewidth.1'\" unpacked with wrong size! fi # end of 'dewidth.1' fi if test -f 'download.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'download.1'\" else echo shar: Extracting \"'download.1'\" \(898 characters\) sed "s/^X//" >'download.1' <<'END_OF_FILE' X.TH DOWNLOAD 1 X.SH NAME Xdownload \- download an HP LaserJet font file X.SH SYNOPSIS X.B download X[ X.B \-d X] [ X.B \-s# X] X.B fontfile... X.SH DESCRIPTION X.I Download Xadds to the named X.I fontfiles Xthe codes necessary to download them to a Hewlett-Packard LaserJet Xprinter and mark them as permanent fonts (i.e. not deleted when the Xprinter is reset). It also assigns successively numbered font i.d.'s to Xthe fonts. The X.I fontfiles Xshould be in standard LaserJet soft font format (see hpfont(5)). X.I Download Xwrites to the standard output; it should be piped to lp(1) or lpr(1). X.PP XOptions: X.TP X.I \-d Xdelete all previously existing soft fonts (even ones marked as permanent) Xfrom the LaserJet's memory before downloading the named X.I fontfiles. X.TP X.I \-s# Xstart numbering the fonts with font i.d. X.I # Xinstead of the default 0. X.SH "SEE ALSO" Xlp(1) or lpr(1), hpfont(5) X.SH AUTHOR XDavid MacKenzie END_OF_FILE if test 898 -ne `wc -c <'download.1'`; then echo shar: \"'download.1'\" unpacked with wrong size! fi # end of 'download.1' fi if test -f 'dumpfont.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'dumpfont.1'\" else echo shar: Extracting \"'dumpfont.1'\" \(1094 characters\) sed "s/^X//" >'dumpfont.1' <<'END_OF_FILE' X.TH DUMPFONT 1 X.SH NAME Xdumpfont \- ASCII display of HP LaserJet font X.SH SYNOPSIS X.B dumpfont X[ X.B \-s X] [ X.B \-c first\-last X] X.B fontfile X.SH DESCRIPTION X.I Dumpfont Xprovides a detailed analysis of an HP LaserJet soft font in numerical Xand graphic form. It first Xdisplays information from the font descriptor, which pertains to the Xfont as a whole; then it produces a plot of each character defined in Xthe font file as a sequence of ASCII characters. X.PP XOptions: X.TP X.I \-s Xproduce summary output only, showing only a list of the characters Xdefined in the file. X.TP X.I \-c first\-last Xrestrict the range of characters displayed to the range X.I first-last, Xinclusive. X.I First Xand X.I last Xare given as literal ASCII characters. Either one may be omitted; they Xdefault to the characters with values 0 and 255, respectively. If they Xboth are omitted, no characters will be displayed. X.SH BUGS X.I Dumpfont Xsometimes displays character plots offset by some amount; why is not Xknown. X.SH "SEE ALSO" Xhpfont(5), X.I "LaserJet Printer Family Technical Reference Manual" X.SH AUTHOR XDavid MacKenzie END_OF_FILE if test 1094 -ne `wc -c <'dumpfont.1'`; then echo shar: \"'dumpfont.1'\" unpacked with wrong size! fi # end of 'dumpfont.1' fi if test -f 'hpwidth.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'hpwidth.1'\" else echo shar: Extracting \"'hpwidth.1'\" \(670 characters\) sed "s/^X//" >'hpwidth.1' <<'END_OF_FILE' X.TH HPWIDTH 1 X.SH NAME Xhpwidth \- produce C troff width table from LaserJet font file X.SH SYNOPSIS X.B hpwidth fontfile X.SH DESCRIPTION X.I Hpwidth Xextracts the width of each character from an HP LaserJet soft font file Xand writes source code for a C character array to the standard output. XWhen compiled, that Xsource code will produce a troff(1) width file in the format of X/usr/lib/font/ft*. The character which each width in the Xarray corresponds to is shown as a C comment. X.SH BUGS XThe widths for certain special characters are constant, and unaffected Xby the contents of the soft font file. X.SH "SEE ALSO" Xdewidth(1), width(1), hpfont(5) X.SH AUTHOR XDavid MacKenzie END_OF_FILE if test 670 -ne `wc -c <'hpwidth.1'`; then echo shar: \"'hpwidth.1'\" unpacked with wrong size! fi # end of 'hpwidth.1' fi if test -f 'installfont.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'installfont.1'\" else echo shar: Extracting \"'installfont.1'\" \(704 characters\) sed "s/^X//" >'installfont.1' <<'END_OF_FILE' X.TH INSTALLFONT 1 X.SH NAME Xinstallfont \- install an HP LaserJet soft font for troff X.SH SYNOPSIS X.B installfont X.SH DESCRIPTION X.I Installfont Xtakes an HP LaserJet soft font file and generates a troff width file and Xa troff2lj hpfontinfo file so that the font can be used by troff. XIt must be run once for each style in a font family X(i.e., Roman, Bold, Italic, any other variation), but for only one Xpointsize within each style (which pointsize you use does not matter). X.PP X.I Installfont Xprompts the user for all needed information. It actually just runs Xhpwidth(1), ccfont(1), and mkhpfi(1) with the appropriate arguments. X.SH "SEE ALSO" Xhpwidth(1), mkhpfi(1), ccfont(1) X.SH AUTHOR XDavid MacKenzie END_OF_FILE if test 704 -ne `wc -c <'installfont.1'`; then echo shar: \"'installfont.1'\" unpacked with wrong size! fi # end of 'installfont.1' fi if test -f 'htroff.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'htroff.1'\" else echo shar: Extracting \"'htroff.1'\" \(785 characters\) sed "s/^X//" >'htroff.1' <<'END_OF_FILE' X.TH HTROFF 1 X.SH NAME Xhtroff \- text formatter for HP LaserJet X.SH SYNOPSIS X.B htroff X[ X.B \-options X] [ X.B files X] X.SH DESCRIPTION X.I Htroff Xis a front end for the troff(1) text formatting program. It sends its Xoutput to a Hewlett-Packard LaserJet or compatible printer. In addition Xto all of the standard troff options, X.I htroff Xalso accepts arguments of the form X.I \-nXX, Xwhich indicate that the font with name X.I XX Xis to be mounted on font position X.I n X(1 <= X.I n X<= 3). Fonts 1-3 default to "R", "I", and "B", (Times Roman, Times XBold, and Times Italic) respectively. X.PP X.I Htroff Xassumes that all requested fonts are already present in the printer. XUse download(1) first if they are not. X.SH "SEE ALSO" Xdownload(1), troff(1) X.SH AUTHORS XSverre Froyen, David MacKenzie END_OF_FILE if test 785 -ne `wc -c <'htroff.1'`; then echo shar: \"'htroff.1'\" unpacked with wrong size! fi # end of 'htroff.1' fi if test -f 'mkhpfi.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mkhpfi.1'\" else echo shar: Extracting \"'mkhpfi.1'\" \(634 characters\) sed "s/^X//" >'mkhpfi.1' <<'END_OF_FILE' X.TH MKHPFI 1 X.SH NAME Xmkhpfi \- make HP fontinfo file from HP soft font file X.SH SYNOPSIS X.B mkhpfi hp_font_file hp_fontinfo_file X.SH DESCRIPTION X.I Mkhpfi Xgenerates an HP fontinfo file, used by troff2lj(1), from an HP soft font Xfile. You should give the X.I hp_fontinfo_file Xa name of the form X.I fiXX, Xand also generate a troff width table for the font using hpwidth(1). XInstallfont(1) does both of these in one step. X.PP XNote that X.I mkhpfi Xgenerates a binary hpfontinfo file directly, without intermediate C Xsource code. X.SH "SEE ALSO" Xhpwidth(1), installfont(1), troff2lj(1), hpfont(5), hpfontinfo(5) X.SH AUTHOR XDavid MacKenzie END_OF_FILE if test 634 -ne `wc -c <'mkhpfi.1'`; then echo shar: \"'mkhpfi.1'\" unpacked with wrong size! fi # end of 'mkhpfi.1' fi if test -f 'troff2lj.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'troff2lj.1'\" else echo shar: Extracting \"'troff2lj.1'\" \(1499 characters\) sed "s/^X//" >'troff2lj.1' <<'END_OF_FILE' X.TH TROFF2LJ 1 X.SH NAME Xtroff2lj \- translate from C/A/T phototypesetter to HP LaserJet X.SH SYNOPSIS X.B troffl2lj X[ X.B \-1xx X] [ X.B \-2xx X] [ X.B \-3xx X] X.SH DESCRIPTION X.I Troff2lj Xis a filter that converts the output of troff(1), which is intended for Xthe Wang C/A/T phototypesetter, into a form suitable for the XHewlett-Packard LaserJet series of printers (and compatibles). XIt assumes that all needed fonts are already present in the printer, Xand, if they are soft fonts, that they are marked as Xpermanent. Soft fonts can be downloaded using the download(1) program. X.PP XBy default, X.I troff2lj Xuses the Times font; however, other fonts can be selected with Xcommand-line options. An argument of the form X.I "\-nXX", Xwhere X.I n Xis a number between 1 and 3, causes X.I troff2lj Xto assume that the font named X.I XX Xhas been mounted on troff's font position X.I n X(using troff's ".fp" command); the practical effect is to cause X.I troff2lj Xto use a different hpfontinfo file when selecting font X.I n. X.SH "SEE ALSO" Xdownload(1), htroff(1), lp(1) or lpr(1), troff(1), hpfontinfo(5) X.SH BUGS XTroff assumes that the character widths scale with the point size. XUnfortunately this is not true for several characters on some LaserJet fonts X(like plus, minus, etc.). The widths for the font of special characters X(font S) are likely to contain errors. X.SH AUTHORS X.TP XSverre Froyen (froyen@nmfecc.arpa) Xmost of the work X.TP XDavid MacKenzie (edf@rocky2.rockefeller.edu) Xmodifications to use non-Times fonts END_OF_FILE if test 1499 -ne `wc -c <'troff2lj.1'`; then echo shar: \"'troff2lj.1'\" unpacked with wrong size! fi # end of 'troff2lj.1' fi if test -f 'width.1' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'width.1'\" else echo shar: Extracting \"'width.1'\" \(1099 characters\) sed "s/^X//" >'width.1' <<'END_OF_FILE' X.TH WIDTH 1 X.SH NAME Xwidth \- produce C troff width table from HP ASCII file X.SH SYNOPSIS X.B width fontfile X.SH DESCRIPTION X.I Width Xextracts the width of each character from an ASCII file provided by XHewlett-Packard for a font cartridge Xand writes source code for a C character array to the standard output. XWhen compiled, that Xsource code will produce a troff(1) width file in the format of X/usr/lib/font/ft*. The character which each width in the Xarray corresponds to is shown as a C comment. XHP supplies font width tables on floppy disk for free (you supply Xthe floppies). They are not copyrighted but they are rather large. XCall your local HP rep. X.PP X.SH BUGS XThe output character table 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. X.SH "SEE ALSO" Xdewidth(1), hpwidth(1), hpfont(5) X.SH AUTHOR XSverre Froyen END_OF_FILE if test 1099 -ne `wc -c <'width.1'`; then echo shar: \"'width.1'\" unpacked with wrong size! fi # end of 'width.1' fi if test -f 'hpfont.5' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'hpfont.5'\" else echo shar: Extracting \"'hpfont.5'\" \(926 characters\) sed "s/^X//" >'hpfont.5' <<'END_OF_FILE' X.TH HPFONT 5 X.SH NAME Xhpfont \- format of HP LaserJet soft font file X.SH SYNOPSIS X(none) X.SH DESCRIPTION XThe format of a standard HP LaserJet soft font file is shown below. XA '#' represents a decimal integer in ASCII form; "ESC" represents the ASCII Xescape character. Words enclosed in brackets ('[' and ']') are not Xliterally present, but are rather binary data; the brackets are not Xactually present in the file, but are shown only for clarity. X.PP XAt top of file: X.TP XESC)s#W[font_descriptor] X(Create font descriptor, # = number of bytes in the font descriptor) X.sp XFor each character: X.TP XESC*c#E X(Specify character code, # = character number) X.TP XESC(s#W[character_descriptor] X(Download character, # = number of bytes of character data that will Xfollow the escape sequence, including the 16 bytes of data in the character Xdescriptor) X.SH "SEE ALSO" Xhpfontinfo(5), X.I "LaserJet Printer Family Technical Reference Manual" END_OF_FILE if test 926 -ne `wc -c <'hpfont.5'`; then echo shar: \"'hpfont.5'\" unpacked with wrong size! fi # end of 'hpfont.5' fi if test -f 'hpfontinfo.5' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'hpfontinfo.5'\" else echo shar: Extracting \"'hpfontinfo.5'\" \(979 characters\) sed "s/^X//" >'hpfontinfo.5' <<'END_OF_FILE' X.TH HPFONTINFO 5 X.SH NAME Xhpfontinfo \- format of HP fontinfo file X.SH SYNOPSIS X(none) X.SH DESCRIPTION XThe format of the hpfontinfo files used by troff2lj(1) is given by the Xfollowing structure: X.nf X.sp X/* X * Characteristics used in selecting a font, in descending order of X * priority. From p.2-19, Technical Reference Manual. X * Symbol set, point size and pitch are dealt with separately. X */ Xstruct hpfontinfo { X /* printing orientation */ X uchar fi_orient; /* 0:portrait, 1:landscape */ X /* proportional vs. fixed spacing */ X uchar fi_spacing; /* 0:fixed, 1:proportional */ X /* character style */ X uchar fi_style; /* 0:upright, 1:italic */ X /* stroke weight (light, medium, bold) */ X schar fi_weight; /* -7 to 7 */ X /* typeface (courier, pica, elite, etc.) */ X uchar fi_typeface; /* 0-10, see table on p. 3-14 */ X}; X.fi X.SH "SEE ALSO" Xmkhpfi(1), troff2lj(1), hpfont(5), X.I "LaserJet Printer Family Technical Reference Manual" END_OF_FILE if test 979 -ne `wc -c <'hpfontinfo.5'`; then echo shar: \"'hpfontinfo.5'\" unpacked with wrong size! fi # end of 'hpfontinfo.5' fi if test -f 'hpconfig.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'hpconfig.h'\" else echo shar: Extracting \"'hpconfig.h'\" \(868 characters\) sed "s/^X//" >'hpconfig.h' <<'END_OF_FILE' X/* X * hpconfig.h X */ X X#ifndef swap16 X X/* X * Locations of HP font files. X */ X X/* Where the LaserJet fonts usually live. */ X#define FONTDIR "/usr/lib/hpfont/" X X/* Prefix for HP fontinfo filenames. */ X#define FINFOPREF "/usr/lib/hpfontinfo/fi" X X/* X * Multibyte numbers in font files are stored high byte first. X * Define LOHI if your machine stores integers low byte first. X */ X X/* These may need to be adjusted for different systems. */ Xtypedef short sint16; /* Signed 16 bit integer. */ Xtypedef unsigned short uint16; /* Unsigned 16 bit integer. */ Xtypedef char schar; /* Signed 8 bit integer. */ Xtypedef unsigned char uchar; /* Unsigned 8 bit integer. */ X X#ifdef LOHI X/* Exchange the two bytes in a 16 bit integer. */ X#define swap16(i) ((i) = (((i) << 8) & 0xff00) | (((i) >> 8) & 0x00ff)) X#else X/* No-op. */ X#define swap16(i) X#endif /* LOHI */ X X#endif /* swap16 */ END_OF_FILE if test 868 -ne `wc -c <'hpconfig.h'`; then echo shar: \"'hpconfig.h'\" unpacked with wrong size! fi # end of 'hpconfig.h' fi if test -f 'hpfinfo.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'hpfinfo.h'\" else echo shar: Extracting \"'hpfinfo.h'\" \(753 characters\) sed "s/^X//" >'hpfinfo.h' <<'END_OF_FILE' X/* X * hpfinfo.h X * X * Format of an HP fontinfo file for troff2lj. X */ X X#include "hpconfig.h" X X/* X * Characteristics used in selecting a font, in descending order of X * priority. From p.2-19, Technical Reference Manual. X * Symbol set and point size are dealt with separately. X */ Xstruct hpfontinfo { X /* printing orientation */ X uchar fi_orient; /* 0:portrait, 1:landscape */ X /* proportional vs. fixed spacing */ X uchar fi_spacing; /* 0:fixed, 1:proportional */ X /* character style */ X uchar fi_style; /* 0:upright, 1:italic */ X /* stroke weight (light, medium, bold) */ X schar fi_weight; /* -7 to 7 */ X /* typeface (courier, pica, elite, etc.) */ X uchar fi_typeface; /* 0-10, see table on p. 3-14 */ X}; END_OF_FILE if test 753 -ne `wc -c <'hpfinfo.h'`; then echo shar: \"'hpfinfo.h'\" unpacked with wrong size! fi # end of 'hpfinfo.h' fi if test -f 'hpfont.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'hpfont.h'\" else echo shar: Extracting \"'hpfont.h'\" \(1919 characters\) sed "s/^X//" >'hpfont.h' <<'END_OF_FILE' X/* X * hpfont.h X * Header for HP LaserJet font manipulation programs. X */ X X#include "hpconfig.h" X X/* X * Font descriptor, p. 3-10 of Technical Reference Manual. X */ X Xtypedef struct { X uint16 f_unu1; /* 26 */ X uchar f_unu2; /* 0 */ X uchar f_type; /* 0:7 bit, 1:8 bit */ X uint16 f_unu3; /* 0 */ X uint16 f_baseline; /* dots from top of char cell to baseline */ X uint16 f_cwidth; /* cell width, 1-255 dots */ X uint16 f_cheight; /* cell height, 1-255 dots */ X uchar f_orient; /* 0:portrait, 1:landscape */ X uchar f_spacing; /* 0:fixed spacing, 1:proportional */ X /* X * (symbol set value field number * 32) + (decimal ASCII value for escape X * sequence terminator, e.g. U, - 64). Symbol set value field numbers are X * listed on p3-12, Tech Ref Man. X */ X uint16 f_symset; X uint16 f_pitch; /* horiz dots/char * 4 (@ 300 dpi, 2-1260) */ X uint16 f_height; /* vertical dots * 4 */ X uint16 f_unu4; /* 0 */ X uchar f_unu5; /* 0 */ X uchar f_style; /* 0:upright, 1:italic */ X schar f_weight; /* -7 to 7 */ X uchar f_typeface; /* 0-10, see table on p. 3-14 */ X} fontdesc; X X/* X * Character descriptor, p. 3-16 of Technical Reference Manual. X */ X Xtypedef struct { X uchar c_unu1; /* 4 */ X uchar c_unu2; /* 0 */ X uchar c_unu3; /* 14 */ X uchar c_unu4; /* 1 */ X uchar c_orient; /* 0:portrait, 1:landscape */ X uchar c_unu5; /* 0 */ X sint16 c_leftoff; /* dots, ref pt to left of pat, -128-127 */ X sint16 c_topoff; /* dots, ref pt to top of pat, -128-127 */ X uint16 c_width; /* 0-128 dots */ X uint16 c_height; /* 0-128 dots */ X sint16 c_delta_x; /* horiz dist in printing char, dots * 4 */ X} chardesc; X X/* X * Variable-length amount of character data. X */ X Xtypedef struct { X char *d_data; X int d_len; /* length of d_data in bytes */ X} chardata; END_OF_FILE if test 1919 -ne `wc -c <'hpfont.h'`; then echo shar: \"'hpfont.h'\" unpacked with wrong size! fi # end of 'hpfont.h' fi if test -f 'dewidth.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'dewidth.c'\" else echo shar: Extracting \"'dewidth.c'\" \(3569 characters\) sed "s/^X//" >'dewidth.c' <<'END_OF_FILE' X/* X * dewidth - decode a troff font width file (/usr/lib/font/ft*) X * into C source code (written to standard output) X * X * Usage: dewidth [-h] ftfile... X * Options: X * -h only print size of object file (hdrb) X * X * David MacKenzie X * Latest revision: 07/24/88 X */ X X/* X * HDRBYTES is the number of bytes taken up by the object file header at X * the top of your troff's font files. Calculated automatically if you X * don't define it manually. X */ X X#ifndef HDRBYTES X#include <a.out.h> X#endif X X#include <stdio.h> X Xchar *tab[] = { X "space", X "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", X "- hyphen", ".", "/", X "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", X ":", ";", "<", "=", ">", "?", "@", X "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", X "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", X "[", "\\", "]", "^", "_", "`", X "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", X "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", X "{", "|", "}", "~", X "narrow space", "hyphen", "bullet", "square", "3/4 em dash", "rule", X "1/4", "1/2", "3/4", "minus", "fi", "fl", "ff", "ffi", "ffl", "degree", X "dagger", "section", "foot mark", "acute acc", X "grave acc", "underrule", "slash", X "half narrow space", "null", "null", "null", "null", "null", "null", X "null", "null", "null", "null", "null", "null", "null", "null", "null", X "null", "null", "null", "null", "null", "null", "null", "null", "null", X "null", "null", "null", "null", "null", "null", "null", "null", "null", X "null", "null", "null", "null", "null", "null", "null", "null", "null", X "null", "null", "null", "null", "null", "null", "null", "null", "null", X "null", "null", "null", "null", "null", "null", "null", "null", "null", X "null", "null", "null", "null", "null", "null", "null", "null", "null", X "null", "registered", "copyright", "null", "cent", "null", "null", X "null", "null", "null", "null", "null", "null", "null", "null", "null", X "null", "null", "null", "null", "null", "null", "null", "null", "null", X "null", "null", "null", "null", "null", "null", "null", "null", "null", X "null", "null" X}; X Xint hdrb; X Xmain(argc, argv) X int argc; X char **argv; X{ X extern int optind; X register int c; X X#ifdef HDRBYTES X /* Defined manually. */ X hdrb = HDRBYTES; X#else X /* Calculate automatically. */ X hdrb = sizeof(struct exec); X#endif X X while ((c = getopt(argc, argv, "h")) != EOF) X switch (c) { X case 'h': X printf("%d\n", hdrb); X exit(0); X default: X usage(argv[0]); X } X if (optind == argc) X usage(argv[0]); X for (; optind < argc; ++optind) X show(argv[optind]); X X exit(0); X} X Xshow(f) X char *f; X{ X char *malloc(); X FILE *fp; X register int c; X register int cval; X char *trash; X X if (hdrb > 0) { X trash = malloc(hdrb); X if (!trash) { X perror("malloc"); X exit(1); X } X } X if (!(fp = fopen(f, "r"))) { X perror(f); X return; X } X printf("char XXw[256-32] = {\n"); X X if (hdrb > 0 && fread(trash, hdrb, 1, fp) != 1) { X perror("fread of header"); X return; X } X for (cval = 0; (c = getc(fp)) != EOF && cval <= 223; ++cval) X if (c & ~077) X printf("%d+%04o%s\t/* %s */\n", c & 077, c & ~077, X cval == 223 ? "" : ",", tab[cval]); X else X printf("%d%s\t\t/* %s */\n", c, X cval == 223 ? "" : ",", tab[cval]); X X printf("};\n"); X X fclose(fp); X} X Xusage(f) X char *f; X{ X fprintf(stderr, "Usage: %s [-h] ftfile...\n", f); X exit(1); X} END_OF_FILE if test 3569 -ne `wc -c <'dewidth.c'`; then echo shar: \"'dewidth.c'\" unpacked with wrong size! fi # end of 'dewidth.c' fi if test -f 'download.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'download.c'\" else echo shar: Extracting \"'download.c'\" \(2387 characters\) sed "s/^X//" >'download.c' <<'END_OF_FILE' X/* X * download - download an HP LaserJet font file X * Usage: download [-d] [-s#] fontfile... X * X * Options: X * -d delete any previously existing soft fonts X * -s# assign font i.d.'s starting with # (default 0) X * X * Writes to the standard output. Should be piped to lpr/lp. X * X * David MacKenzie X * Latest revision: 07/19/88 X */ X X#include <stdio.h> X#include "hpconfig.h" X Xmain(argc, argv) X int argc; X char **argv; X{ X extern char *optarg; X extern int optind; X int c; X int fid = 0; X X translate(); X X while ((c = getopt(argc, argv, "ds:")) != EOF) X switch (c) { X case 'd': X delfonts(); X break; X case 's': X fid = atoi(optarg); X break; X default: X usage(argv[0]); X } X X if (optind == argc) X usage(argv[0]); X else X for (; optind < argc; ++optind) X download(argv[optind], fid++); X X exit(0); X} X X/* X * Open given font file; if leading directory is not specified, assume X * it's in the standard one. X */ XFILE * Xopenfont(file) X register char *file; X{ X FILE *ff; X char path[BUFSIZ]; X X if (file[0] != '/') X strcpy(path, FONTDIR); X else X path[0] = 0; X strcat(path, file); X if (!(ff = fopen(path, "r"))) X perror(path); X return ff; X} X X/* X * Send the codes to download a font file. X */ X Xdownload(file, fid) X char *file; X int fid; X{ X FILE *openfont(); X FILE *ff; X register int c; X X if (!(ff = openfont(file))) X return; X X specfid(fid); X X while ((c = getc(ff)) != EOF) X putc(c, stdout); X fclose(ff); X X select(fid); X} X X/* X * Make the font with the specified i.d. permanent. X */ X Xselect(fid) X int fid; X{ X specfid(fid); X permanent(); X} X X/* X * Specify font i.d. X */ Xspecfid(fid) X int fid; X{ X printf("\033*c%dD", fid); X} X X/* X * Make the last specified font permanent (not cleared by printer reset). X */ Xpermanent() X{ X printf("\033*c5F"); X} X X/* X * Delete all downloaded fonts, freeing up the printer's memory. X */ Xdelfonts() X{ X printf("\033*c0F"); X} X X/* X * We assume there are no newline translations occurring on the printer X * port, so as not to mangle downloaded fonts. Therefore, make sure X * that the printer is doing them. X * p. 2-45, 2: CR=>CR; LF=>CRLF; FF=>CRFF X */ Xtranslate() X{ X printf("\033&k2G"); X} X Xusage(file) X char *file; X{ X fprintf(stderr, "Usage: %s [-d] [-s#] fontfile...\n", file); X exit(1); X} END_OF_FILE if test 2387 -ne `wc -c <'download.c'`; then echo shar: \"'download.c'\" unpacked with wrong size! fi # end of 'download.c' fi if test -f 'dumpfont.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'dumpfont.c'\" else echo shar: Extracting \"'dumpfont.c'\" \(8277 characters\) sed "s/^X//" >'dumpfont.c' <<'END_OF_FILE' X/* X * dumpfont - ASCII display of HP LaserJet font X * Usage: dumpfont [-s] [-c first-last] fontfile X * Options: X * -s summary output only X * -c first-last restrict range of chars dumped X * X * David MacKenzie X * Latest revision: 07/26/88 X */ X X#include <stdio.h> X#include "hpfont.h" X Xint sflag = 0; X Xmain(argc, argv) X int argc; X char **argv; X{ X extern int optind; X extern char *optarg; X int c; X int first = 0; /* First char to dump. */ X int last = 255; /* Last char to dump. */ X X while ((c = getopt(argc, argv, "sc:")) != EOF) X switch (c) { X case 's': X sflag = 1; X break; X case 'c': X parserange(optarg, &first, &last); X break; X default: X usage(argv[0]); X } X if (optind != argc - 1) X usage(argv[0]); X dumpfont(argv[optind], first, last); X exit(0); X} X/* X * Parse a character range of the form a-b, where a and b are X * optional ASCII characters. X */ X Xparserange(range, first, last) X char *range; X int *first; X int *last; X{ X if (!*range) { X /* Null range: print none of the characters. */ X *first = 256; X *last = -1; X return; X } else if (*range != '-') X *first = *range++; X else X *first = 0; X if (*range++ != '-') X err("Illegal character range"); X if (!*range) X *last = 255; X else X *last = *range; X if (*last < *first) X err("Last character is less than first character"); X} X Xdumpfont(file, first, last) X char *file; X register int first; X register int last; X{ X FILE *fp; X char path[150]; X fontdesc fd; X chardesc cde; X chardata cda; X register int ccode; X X if (*file != '/') X strcpy(path, FONTDIR); X else X path[0] = 0; X strcat(path, file); X if (!(fp = fopen(path, "r"))) { X perror(path); X exit(1); X } X printf("file: %s\n\n", file); X X readfontdesc(fp, &fd); X if (!sflag) { X dumpfdesc(&fd); X printf("\n"); X } X while ((ccode = readchar(fp, &cde, &cda)) != EOF) { X if (ccode >= first && ccode <= last) { X printf("character %3d", ccode); X if (ccode > 32 && ccode < 127) X printf(" (%c)", ccode); X printf(":\n"); X if (!sflag) { X dumpchar(&fd, &cde, &cda); X printf("\n"); X } X } X free(cda.d_data); X } X fclose(fp); X} X Xreadfontdesc(fp, fdp) X FILE *fp; X fontdesc *fdp; X{ X char buf[500]; /* Trash receptacle. */ X int fdlen; /* No. of bytes in font descriptor. */ X X if (fscanf(fp, "\033)s%dW", &fdlen) != 1) X err("Can't read font creation sequence"); X if (!fread(fdp, sizeof(fontdesc), 1, fp)) X err("Can't read font descriptor"); X if (fdlen > sizeof(fontdesc)) X if (!fread(buf, fdlen - sizeof(fontdesc), 1, fp)) X err("Can't read continuation of font descriptor"); X /* Swap byte order in integers if necessary. */ X swap16(fdp->f_baseline); X swap16(fdp->f_cwidth); X swap16(fdp->f_cheight); X swap16(fdp->f_symset); X swap16(fdp->f_pitch); X swap16(fdp->f_height); X} X Xdumpfdesc(fdp) X fontdesc *fdp; X{ X /* From p. 3-14, Technical Reference Manual. */ X static char *tftab[] = { X "Line Printer", "Pica", "Elite", "Courier", "Helvetica", X "Times Roman", "Gothic", "Script", "Prestige", "Caslon", X "Orator" X }; X /* From p. 3-12, Technical Reference Manual. */ X static struct { X int field; X char term; X char *desc; X } sstab[] = { X 8, 'U', "Roman-8", X 8, 'K', "Kana-8", X 8, 'M', "Math-8", X 0, 'U', "USASCII", X 0, 'B', "Line Draw", X 0, 'A', "Math Symbols", X 1, 'U', "US Legal", X 0, 'E', "Roman Extension", X 0, 'D', "ISO Denmark/Norway", X 1, 'E', "ISO United Kingdom", X 0, 'F', "ISO France", X 0, 'G', "ISO German", X 0, 'I', "ISO Italy", X 0, 'S', "ISO Sweden/Finland", X 1, 'S', "ISO Spain", X 0, 0, NULL X }; X X int field; X char term; X register int i; X X printf("font type (bits): %d\n", fdp->f_type + 7); X printf("from top of cell to baseline (dots): %d\n", fdp->f_baseline); X printf("cell width (dots): %d\n", fdp->f_cwidth); X printf("cell height (dots): %d\n", fdp->f_cheight); X printf("orientation: %s\n", fdp->f_orient ? X "landscape" : "portrait"); X printf("spacing: %s\n", fdp->f_spacing ? X "proportional" : "fixed"); X X field = (fdp->f_symset >> 5) & 0x0f; X term = (fdp->f_symset & 0x1f) | 64; X printf("symbol set: %d = %d%c", fdp->f_symset, field, term); X for (i = 0; sstab[i].desc; ++i) X if (field == sstab[i].field && term == sstab[i].term) { X printf(" (%s)\n", sstab[i].desc); X break; X } X if (!sstab[i].desc) X printf(" (unknown)\n"); X X printf("pitch (horizontal dots per character): %g\n", fdp->f_pitch / 4.0); X printf("vertical dots per character: %g\n", fdp->f_height / 4.0); X printf("style: %s\n", fdp->f_style ? "italic" : "upright"); X printf("stroke weight: %d\n", fdp->f_weight); X printf("typeface: %d", fdp->f_typeface); X if (fdp->f_typeface < 11) X printf(" (%s)\n", tftab[fdp->f_typeface]); X else X printf(" (unknown)\n"); X /* Points = quarter_dots / 4 * 72 / 300. */ X printf("point size: %d\n", (int) ((double) fdp->f_height * 0.06)); X} X Xreadchar(fp, cdep, cdap) X FILE *fp; X chardesc *cdep; X chardata *cdap; X{ X char *Malloc(); X int ccode; /* Character code (character number). */ X int cdlen; /* No. of bytes in character descriptor. */ X X switch (fscanf(fp, "\033*c%dE", &ccode)) { X case 1: X break; X case EOF: X return EOF; X default: X err("Can't read character code"); X } X if (fscanf(fp, "\033(s%dW", &cdlen) != 1) X err("Can't read character download sequence"); X if (!fread(cdep, sizeof(chardesc), 1, fp)) X err("Can't read character descriptor"); X /* Swap byte order in integers if necessary. */ X swap16(cdep->c_leftoff); X swap16(cdep->c_topoff); X swap16(cdep->c_width); X swap16(cdep->c_height); X swap16(cdep->c_delta_x); X X cdap->d_len = cdlen - sizeof(chardesc); X cdap->d_data = Malloc(cdap->d_len); X if (!fread(cdap->d_data, cdap->d_len, 1, fp)) X err("Can't read character data"); X return ccode; X} X Xdumpchar(fdp, cdep, cdap) X fontdesc *fdp; X chardesc *cdep; X chardata *cdap; X{ X dumpcdesc(cdep); X plotchar(fdp, cdep, cdap); X} X Xdumpcdesc(cdep) X chardesc *cdep; X{ X printf("orientation: %s\n", cdep->c_orient ? X "landscape" : "portrait"); X} X X/* X * The main loop for plotting a character. X */ X Xplotchar(fdp, cdep, cdap) X fontdesc *fdp; X chardesc *cdep; X chardata *cdap; X{ X register int x,y; /* First row & col are numbered 1. */ X char graphchar; X X initplot(cdap); X for (y = 1; y <= fdp->f_cheight; ++y) { X for (x = 1; x <= fdp->f_cwidth; ++x) { X graphchar = inbox(x, y, fdp, cdep) ? X nextdot(cdep) ? '*' : '-' : X y == fdp->f_baseline + 1 ? '=' : X '.'; X putchar(graphchar); X } X if (y == fdp->f_baseline + 1) X printf(" baseline"); X putchar('\n'); X } X} X Xstatic char *bytep; /* Byte being dissected. */ Xstatic char masknum; /* Index into masktab to mask off bit. */ Xstatic int bitcnt; /* Number of current bit in current row. */ X X/* X * Set up for nextdot(). X */ X Xinitplot(cdap) X chardata *cdap; X{ X bytep = cdap->d_data; X masknum = 0; X bitcnt = 0; X} X X/* X * Boolean: is the next dot on? X */ X Xnextdot(cdep) X chardesc *cdep; X{ X /* Table to isolate bit currently being analyzed. */ X static char masktab[] = { 128, 64, 32, 16, 8, 4, 2, 1 }; X int val; /* Return value. */ X X val = *bytep & masktab[masknum]; X /* Check if we've reached the end of a row. */ X if (++bitcnt == cdep->c_width) { X /* Skip the byte boundary padding bits. */ X ++bytep; X masknum = 0; X bitcnt = 0; X } else if (++masknum == 8) { X /* Go on to the next byte. */ X ++bytep; X masknum = 0; X } X return val; X} X X/* X * Boolean: is point (x,y) in the character box? X */ X Xinbox(x, y, fdp, cdep) X register int x, y; X fontdesc *fdp; X chardesc *cdep; X{ X return y >= fdp->f_baseline - cdep->c_topoff + 1 && X y <= fdp->f_baseline - cdep->c_topoff + cdep->c_height && X x >= cdep->c_leftoff && X x <= cdep->c_leftoff + cdep->c_width - 1; X} X Xchar * XMalloc(size) X unsigned size; X{ X char *malloc(); X register char *s; X X if (!(s = malloc(size))) { X perror("malloc"); X exit(1); X } X return s; X} X Xerr(s) X char *s; X{ X fprintf(stderr, "%s\n", s); X exit(1); X} X Xusage(file) X char *file; X{ X fprintf(stderr, "Usage: %s [-s] [-c first-last] fontfile\n", file); X exit(1); X} END_OF_FILE if test 8277 -ne `wc -c <'dumpfont.c'`; then echo shar: \"'dumpfont.c'\" unpacked with wrong size! fi # end of 'dumpfont.c' fi if test -f 'hpwidth.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'hpwidth.c'\" else echo shar: Extracting \"'hpwidth.c'\" \(4514 characters\) sed "s/^X//" >'hpwidth.c' <<'END_OF_FILE' X/* xc X% cc -O hpwidth.c -o hpwidth X% strip hpwidth X */ X/* X * hpwidth - width display of HP LaserJet font X * Usage: hpwidth fontfile X * X * Output is in the form of C source code. X * X * David MacKenzie X * Latest revision: 07/14/88 X */ X X/* X * The widths of the characters are adjusted by SCALE. X * X * I did arrive at 0.864 by looking at the versatec driver. It is X * (54/25)*(6/10)*(200/300). I do not know how those numbers came about. X * -Sverre X */ X#define SCALE 8.64 / ps X X#include <stdio.h> X#include "hpfont.h" X Xmain(argc, argv) X int argc; X char **argv; X{ X if (argc != 2) X usage(argv[0]); X dumpfont(argv[1]); X X exit(0); X} X XFILE * Xopenfont(file) X register char *file; X{ X FILE *fp; X char path[150]; X X if (*file != '/') X strcpy(path, FONTDIR); X else X path[0] = 0; X strcat(path, file); X if (!(fp = fopen(path, "r"))) { X perror(path); X exit(1); X } X return fp; X} X Xdumpfont(file) X char *file; X{ X FILE *openfont(); X FILE *fp; X fontdesc fd; X chardesc cde; X chardata cda; X register int ps; /* Point size. */ X register int ccode; X register int width; X X fp = openfont(file); X X readfontdesc(fp, &fd); X /* Points = quarter_dots / 4 * 72 / 300. */ X ps = (int) ((double) fd.f_height * 0.06); X X printf("char XXw [256-32] = {\n"); X printf("12,\t/* space */\n"); X X while ((ccode = readchar(fp, &cde, &cda)) != EOF) { X if (ccode <= '~') { X if (index("\"#<>@\\^_{}~", ccode)) X width = 0; X else X width = (int) ((float) cde.c_delta_x / 4.0 * SCALE + 0.5); X printf("%d,\t/* %c */\n", width, ccode); X free(cda.d_data); X } X } X fclose(fp); X X printf("6,\t\t/* narrow space */\n"); X printf("20,\t\t/* hyphen */\n"); X printf("12,\t\t/* bullet */\n"); X printf("22,\t\t/* square */\n"); X printf("33,\t\t/* 3/4 em dash */\n"); X printf("30,\t\t/* rule */\n"); X printf("18,\t\t/* 1/4 */\n"); X printf("18,\t\t/* 1/2 */\n"); X printf("0,\t\t/* 3/4 */\n"); X printf("20,\t\t/* minus */\n"); X printf("0,\t\t/* fi */\n"); X printf("0,\t\t/* fl */\n"); X printf("0,\t\t/* ff */\n"); X printf("0,\t\t/* ffi */\n"); X printf("0,\t\t/* ffl */\n"); X printf("14,\t\t/* degree */\n"); X printf("16,\t\t/* dagger */\n"); X printf("0,\t\t/* section */\n"); X printf("8,\t\t/* foot mark */\n"); X printf("0,\t\t/* acute acc */\n"); X printf("0,\t\t/* grave acc */\n"); X printf("0,\t\t/* underrule */\n"); X printf("0,\t\t/* slash */\n"); X printf("3,\t\t/* half narrow space */\n"); X for (ccode = 1; ccode <= 70; ++ccode) X printf("0,\t\t/* null */\n"); X printf("22,\t\t/* registered */\n"); X printf("22,\t\t/* copyright */\n"); X printf("0,\t\t/* null */\n"); X printf("21,\t\t/* cent */\n"); X for (ccode = 1; ccode <= 30; ++ccode) X printf("0,\t\t/* null */\n"); X printf("0\t\t/* null */\n"); X printf("}; /* from file %s, ps=%d */\n", file, ps); X} X Xreadfontdesc(fp, fdp) X FILE *fp; X fontdesc *fdp; X{ X char buf[500]; /* Trash receptacle. */ X int fdlen; /* No. of bytes in font descriptor. */ X X if (fscanf(fp, "\033)s%dW", &fdlen) != 1) X err("Can't read font creation sequence"); X if (!fread(fdp, sizeof(fontdesc), 1, fp)) X err("Can't read font descriptor"); X if (fdlen > sizeof(fontdesc)) X if (!fread(buf, fdlen - sizeof(fontdesc), 1, fp)) X err("Can't read continuation of font descriptor"); X} X Xreadchar(fp, cdep, cdap) X FILE *fp; X chardesc *cdep; X chardata *cdap; X{ X char *Malloc(); X int ccode; /* Character code (character number). */ X int cdlen; /* No. of bytes in character descriptor. */ X X switch (fscanf(fp, "\033*c%dE", &ccode)) { X case 1: X break; X case EOF: X return EOF; X default: X fprintf(stderr, "Can't read character code\n"); X return EOF; X } X if (fscanf(fp, "\033(s%dW", &cdlen) != 1) X err("Can't read character download sequence"); X if (!fread(cdep, sizeof(chardesc), 1, fp)) X err("Can't read character descriptor"); X cdap->d_len = cdlen - sizeof(chardesc); X cdap->d_data = Malloc(cdap->d_len); X if (!fread(cdap->d_data, cdap->d_len, 1, fp)) X err("Can't read character data"); X return ccode; X} X Xchar * XMalloc(size) X unsigned size; X{ X char *malloc(); X register char *s; X X if (!(s = malloc(size))) { X perror("malloc"); X exit(1); X } X return s; X} X Xerr(s) X char *s; X{ X fprintf(stderr, "%s\n", s); X exit(1); X} X Xusage(file) X char *file; X{ X fprintf(stderr, "Usage: %s fontfile\n", file); X exit(1); X} END_OF_FILE if test 4514 -ne `wc -c <'hpwidth.c'`; then echo shar: \"'hpwidth.c'\" unpacked with wrong size! fi # end of 'hpwidth.c' fi if test -f 'mkhpfi.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mkhpfi.c'\" else echo shar: Extracting \"'mkhpfi.c'\" \(2315 characters\) sed "s/^X//" >'mkhpfi.c' <<'END_OF_FILE' X/* X * mkhpfi - generate HP fontinfo file from HP font file X * X * Usage: mkhpfi hp_font_file hp_fontinfo_file X * You should call the fontinfo file "fiXX", where XX is a one or two X * character font name. X * X * Outputs a binary HP fontinfo file. X * X * For soft fonts downloaded from disk, use this program. X * For fonts resident in font cartridges, you'll have to manually create X * and compile a C source module defining a struct hpfontinfo. X * X * David MacKenzie X * Latest revision: 07/21/88 X */ X X#include <stdio.h> X#include "hpfont.h" X#include "hpfinfo.h" X Xmain(argc, argv) X int argc; X char **argv; X{ X if (argc != 3) { X fprintf(stderr, "Usage: %s hp_font_file hp_fontinfo_file\n", argv[0]); X exit(1); X } X makefinfo(argv[1], argv[2]); X} X X/* X * Generate an HP fontinfo file called info based on the HP font file X * called font. X */ Xmakefinfo(font, info) X char *font, *info; X{ X FILE *ifp, *ofp; X fontdesc fd; X struct hpfontinfo fi; X X ifp = fopen(font, "r"); X if (!ifp) { X perror(font); X exit(1); X } X ofp = fopen(info, "w"); X if (!ofp) { X perror(info); X exit(1); X } X X readfontdesc(ifp, &fd); X convert(&fd, &fi); X writefinfo(ofp, &fi); X X fclose(ofp); X fclose(ifp); X} X Xreadfontdesc(fp, fdp) X FILE *fp; X fontdesc *fdp; X{ X char buf[500]; /* Trash receptacle. */ X int fdlen; /* No. of bytes in font descriptor. */ X X if (fscanf(fp, "\033)s%dW", &fdlen) != 1) X err("Can't read font creation sequence"); X if (!fread(fdp, sizeof(fontdesc), 1, fp)) X err("Can't read font descriptor"); X /* Not necessary, but we might as well, for error checking. */ X if (fdlen > sizeof(fontdesc)) X if (!fread(buf, fdlen - sizeof(fontdesc), 1, fp)) X err("Can't read continuation of font descriptor"); X} X X/* X * Fill in a struct hpfontinfo based on a fontdesc. X */ Xconvert(fdp, fip) X fontdesc *fdp; X struct hpfontinfo *fip; X{ X fip->fi_orient = fdp->f_orient; X fip->fi_spacing = fdp->f_spacing; X fip->fi_style = fdp->f_style; X fip->fi_weight = fdp->f_weight; X fip->fi_typeface = fdp->f_typeface; X} X Xwritefinfo(fp, fip) X FILE *fp; X struct hpfontinfo *fip; X{ X if (fwrite(fip, sizeof(struct hpfontinfo), 1, fp) != 1) X perror("fwrite"); X} X Xerr(s) X char *s; X{ X fprintf(stderr, "%s\n", s); X exit(1); X} END_OF_FILE if test 2315 -ne `wc -c <'mkhpfi.c'`; then echo shar: \"'mkhpfi.c'\" unpacked with wrong size! fi # end of 'mkhpfi.c' fi if test -f 'select.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'select.c'\" else echo shar: Extracting \"'select.c'\" \(1478 characters\) sed "s/^X//" >'select.c' <<'END_OF_FILE' X/* X * select.c X * X * troff2lj soft font selection routines. X */ X X#include <stdio.h> X#include "hpfinfo.h" X Xextern char *prog_name; X Xstatic struct hpfontinfo hpftab[3]; X X/* X * Initialize hpftab from the files in FINFOPREF with suffices specified X * in fnames[0-2] (default "R", "I", "B"). X */ Xhp_init_fonts(fnames) X char **fnames; X{ X register int i; X X for (i = 0; i < 3; ++i) X hp_read_info(fnames[i], &hpftab[i]); X} X X/* X * Initialize one entry of hpftab. X */ Xhp_read_info(name, info) X char *name; X struct hpfontinfo *info; X{ X FILE *fp; X char path[BUFSIZ]; X X strcpy(path, FINFOPREF); X strcat(path, name); X if (!(fp = fopen(path, "r"))) { X fprintf(stderr, "%s: ", prog_name); X perror(path); X } else { X if (fread(info, sizeof(info), 1, fp) != 1) X fprintf(stderr, "%s: %s is corrupt\n", prog_name, path); X fclose(fp); X } X} X X/* X * Send the codes to select the font mounted on position n (1-3). X */ Xhp_sel_font(n) X register int n; X{ X if (n >= 1 && n <= 3) X hp_spec_font(&hpftab[n - 1]); X else X fprintf(stderr, "%s: Illegal font selection %d\n", prog_name, n); X} X X/* X * Send the codes necessary to specify a LaserJet font, except for point X * size/pitch and symbol set (dealt with by other functions). X */ Xhp_spec_font(ip) X struct hpfontinfo *ip; X{ X printf("\033&l%dO", ip->fi_orient); X printf("\033(s%dp", ip->fi_spacing); X printf("%ds", ip->fi_style); X printf("%db", ip->fi_weight); X printf("%dT", ip->fi_typeface); X} END_OF_FILE if test 1478 -ne `wc -c <'select.c'`; then echo shar: \"'select.c'\" unpacked with wrong size! fi # end of 'select.c' fi if test -f 'ccfinfo' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ccfinfo'\" else echo shar: Extracting \"'ccfinfo'\" \(341 characters\) sed "s/^X//" >'ccfinfo' <<'END_OF_FILE' X: X# ccfinfo X# X# Input: fiXX.c file, made by hand X# Output: fiXX file, usable by troff2lj when put in /usr/lib/hpfontinfo X# X# Sample usage: ccfinfo fihR X# X# David MacKenzie X# Latest revision: 07/24/88 X Xhdrbytes=`dewidth -h` X Xfor font Xdo X cc -c $font.c X strip $font.o X dd skip=$hdrbytes ibs=1 if=$font.o of=$font X rm $font.o Xdone END_OF_FILE if test 341 -ne `wc -c <'ccfinfo'`; then echo shar: \"'ccfinfo'\" unpacked with wrong size! fi chmod +x 'ccfinfo' # end of 'ccfinfo' fi echo shar: End of archive 1 \(of 2\). cp /dev/null ark1isdone MISSING="" for I in 1 2 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked both 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