[tex-k] basic kpse_find_{format} question

Karl Berry karl at freefriends.org
Sat Sep 13 00:17:35 CEST 2008


Hi Daniel,

    I'm currently writing an open-source DVI previewer that will suit my
    own eccentric needs.  

If it ends up working on Windows, that would be especially wonderful.

    How does one find the format of a given fontname that one reads from
    a DVI file?

The DVI file just records the TFM file name as seen by TeX.  It is up to
the driver to figure out what files to look for in what order.  Kpathsea
has lots of functions in this area, but there is no one single thing
to call.

In other words, there is no single format.  The existing drivers search
for .vf's, possibly check for scalable fonts (e.g., psfonts.map), then
look for pk/gf (making them if necessary), and finally fall back to tfm.

    Do I have to set up my own hash table in my program that matches
    font names to file formats?

It's more complex than a simple hash table ...

    but does KPathSea have a special function that will search some file
    database file or config file which matches font file names (as
    retrieved from DVI files) with their format type?  

The basic function is kpse_find_file.  You probably already knew that.

    I guess I could always do a manual search in the ls-R file in
    /var/lib/texmf, but then I wouldn't need to run kpse_find_{format}.

No, you don't want to do that.  There is a whole hierarchy of ls-R files
(and their texmf trees) to look in.

    I guess I could also run a find command as a system call, 

You want to do that even less.

    but then my program wouldn't be portable for Windows, and would
    perhaps be slightly less efficient.

Slightly?  More likely unusably inefficient :).  TeX trees are hundreds
of megabytes these days.


I strongly recommend looking at the existing drivers, dvipsk (search.c)
and xdvik (font-open.c), dviljk, dvipdfmx.  The sources for all of them
are in TeX Live, see http://tug.org/texlive/svn for info about the
source tree.

There's no way to describe everything that needs to be done.  It has all
evolved over many years, and is one of the most complicated and painful
parts of the system.  And yet unless it is done compatibly, the program
will not work with real-life existing TeX installations.  Sorry.

Happy hacking.

Karl


More information about the tex-k mailing list