[comp.text] Wanted: Help with dvi2ps and built-in Adobe fonts.

wesommer@bacchus.UUCP (03/01/87)

A month or so ago, a program was posted to the net to convert Adobe
afm Font Metric files into TeX PL files (which can then get compiled
into TFM files, for use from TeX and LaTeX).  Unfortunately, dvi2ps
couldn't grok the dvi files which TeX then produced (it couldn't find
pxl files for Times-Roman, etc).

After a fair amount of hacking, I found (empirically) the appropriate
conversion factor between the TeX magnification levels and the
(non-standard) PostScript scaling in the environment set up by the TeX
preamble.  This took a bit of black magic and the sacrifice of a
reasonably large amount of paper.

I also modified dvi2ps to output PostScript commands to (a) create
PostScript (scaleable) fonts which had been diddled to correspond to
the TeX scaling system (it basically means taking the existing builtin
font and replacing its scaling matrix) and (b) take these fonts and
produce more scaleable ones on demand.  In other words:


I added this to tex.ps:

      % This constant was determined empirically.
      /TeXscale 83.0 30000000.0 div def

      /newbuiltinfont
      { findfont dup length dict /newdict exch def
         { 1 index /FID ne
            { newdict 3 1 roll put }
            { pop pop }
            ifelse
         } forall
         newdict /FontMatrix [ TeXscale 0 0 TeXscale neg 0 0 ] put
         newdict definefont pop
      } bind def

and modified dvi2ps to output commands of the following form instead
of downloading fonts using @newfont and @dc (by the way, the TeX mag
scaling in the PostScript tfm files seems to be that 1500 = 1 point,
so this is for 12 point Times-Roman)

      /TexTimes-Roman /Times-Roman newbuiltinfont
      /Times-Roman.18000 /TexTimes-Roman findfont 18000 scalefont def

This (almost) worked correctly.  My one remaining problem is that,
since DVI files appear use relative positioning, and the output of
dvi2ps uses absolute positioning commands, dvi2ps needs to know about
font width information.  This actually doesn't bite you unless you use
superscripts or math...  but then, that's what TeX was designed for.

I see two possible ways around this:
 - change the PostScript output to look more like DVI-turned-to-ascii,
and thus contain its own PUSH, POP, and relative positioning commands.
This has the advantage that dvi2ps gets simpler (probably simple
enough to graft into ctex itself..).  This also means that the printer
will spend more time interpreting the PostScript, as well as using up
a lot more stack space.

 - have dvi2ps be able to read and scale tfm and/or afm files.  The
format of the tfm file (as well as the code in ctex to read it in)
appears to be rather opaque at a first reading, so I'm not sure I want
to go this route.

Has anyone out there done this already and have any pointers on this?
Thanks in advance.

				Bill Sommerfeld
				MIT Project Athena
			  ARPA: <wesommer@athena.mit.edu>
			  UUCP: ...!mit-eddie!wesommer