These are the sources for a ditroff (not troff) to TeX DVI converter.
I wrote this on a lark and to learn DVI format. Some reasons why you
may want this:

+ Your high resolution printer accepts DVI but you don't have a ditroff
filter for it.

+ You want to access the wide range of characters in TeX fonts.

+ You want to create weird and wonderful fonts for ditroff with METAFONT.

+ You have only a DVI previewer.

+ You want to standardize on one type of output.

+ You want to give the operator of a non-Unix machine a fit by printing
a Unix man page on the DVI printer.

+ (Put your own reason here.)

It works pretty well and I have printed tens of pages of documentation
with it.

You may do whatever you like with the source, except make money out of
it (because I gave it to you for free to begin with).  Do leave my name
in this documentation.

How it works:

Edit Makefile to specify where the TeX tfm files live and where ditroff
expects to find the binary tables.

The files cm* define the fonts of a virtual printer called dvi.  You
run the program tfm2desc to generate font tables in the files R, I, B,
etc. See the man page for tfm2desc and the Makefile entry for metrics
for flags to tfm2desc.  Make all, then run makedev (in your ditroff
distribution, not supplied here) or a PD version of that to make binary
font tables for ditroff.  Install these binary tables in a subdirectory
called devdvi near where ditroff expects to find other tables.

If you want to add fonts, make up more cm* description files and edit
Makefile to add the font names. You have to estimate the spacewidth
passed to tfm2desc. I use half of the width of a digit.  cmss isn't
really Helvetica, just sort of sans serif.

The resolution of this virtual printer is irrelevant so I've set it at
576 (8*72). You can change this in the Makefile.  You must choose a
unitwidth such that all the character widths are under 256, because
ditroff stores the widths in single bytes. The roundoff error will be
minimized if the widths are as large as possible.  Fortunately for
ditroff, the resolution of DVI files is much higher than anything
ditroff can comprehend. (1 / 2^16 of a point, if you are curious.)

Sizes 10 and below are translated to TeX fonts at their respective
design size. Above that, magnification is used. Hence the code to
translate size to magnification in reader.c. Most TeX fonts follow this
pattern of availability. Unfortunately the SIZES macro in the Makefile
isn't all you have to change if you want to add more sizes. You also
have to edit the switch statement in reader.c and make sure you have
the fonts in the right design size and magnification.

Note that if you don't have a font of the right size, you don't find
out until you try to print the DVI file, or convert it to your printer
language.

There is no room for the spaces or rule characters in the TeX character
set, so I've put spaces at 0200 and the rule at 0201. The constant 0201
is hacked into tfm2desc and ditdvi. Sorry.

I haven't tried out how well extended parens, brackets and braces are
drawn with eqn.

Drawing functions are not implemented. You can translate these to tpic
generated \specials. I'm too lazy.

Some special characters must be provided to ditroff or it will have a
fit or at least drop your characters silently.  These include hyphen
(hy), mathtimes (**), vertical bar (bv), the spaces and rule. The whole
sordid story can be read in "Adventures with Typesetter Independent
Troff" by Moore and Kahrs, TR 159, June 1985, Computer Science Dept.,
U. of Rochester.  It's fascinating how much knowledge of the special
fonts is still hardwired into ditroff.

There is one potential bug in fontfile.c. A pointer to a table of
shorts may be non-word aligned. Some machines don't like this.  You
need to do a block copy to malloc'ed memory. Again, I was lazy.

If you have old troff, my condolences. Have fun.

You can send me bug reports but I'm not too motivated to do much about
them.

	Ken Yap
	ken@cs.rochester.edu
	April 1988
