[texhax] using latex from an external plotting package

Karl Berry karl at freefriends.org
Tue Feb 7 20:20:01 CET 2006

    if there is an open source dvi parser available that is compatible
    with the python (BSD) license?

Sure, tons.  I kind of had the impression that someone had already
written some Python packages to parse DVI, if that's your preferred
language.  I know there are Perl packages for it, poke around on
cpan.org for them.

And of course there are tons of DVI utilities in the TeX distributions,
starting with dvitype, the one Phil mentioned.  It also precisely
defines the DVI file format so you could write your own if need be.

    Is that a big IF? 

Yes, that is a big if.  At least I don't know the answer -- if you can
just pass in a filename, or if some processing has to happen first.

    I believe freetype works with AFM files, but dvi files seem 
    to reference tfm/vf files. Does anyone know if the tfm/vf information is 
    applicable to afm fonts? For example, a dvi file might reference 
    phvr7t.vf/phvr7t.tfm, but the helvetica afm file is phvr8a.afm. 

There are several confusions here.

- afm files and tfm files are both just metrics -- character
  widths, heights, kerning, etc., but no actual shapes.

- tfm and afm can be converted to each other, they are quite similar in
  the information they provide.  For the direction you care about, the
  only program I know about is tfm2afm.scm, part of GNU Lilypond.  No
  idea how easy it would be to adapt, but even writing a converter from
  scratch is not that big a deal.
  In your case, if TeX uses a font foobar.tfm, I would not attempt to
  find a corresponding foobar.afm.  In many cases it won't exist, and
  even if it does, it more than likely will be wrong.  Just convert it
  and save it yourself.

- the actual shapes are defined mostly in PostScript Type 1 fonts for
  TeX.  These days most everything else uses TrueType or OpenType.
  These can be converted to, most easily (in our world) with fontforge.
  I don't know what freetype supports.

- dvi files (and TeX itself) don't reference vf at all.  They only
  reference tfm's.  It is dvi reading programs which decide to look for
  foo.vf when they see "foo" in the DVI file, based on whatever criteria
  they come up with.

- There is lots of documentation on all this stuff; some google searches
  or searches on tug.org/ctan.html should lead you to some helpful


More information about the texhax mailing list