Paul Isambert zappathustra at free.fr
Wed Jun 5 11:28:41 CEST 2013

Hello Sam,

Sam Brown <s_d_j_brown at hotmail.com> a écrit:
> Dear all texhaxers
>
> I am wanting to write a document that displays all the fonts available on my
> system. To do this I've enlisted a batch script that returns all .tfm files in
> my texmf tree, which is then processed with R to create a LaTeX file with every
> font available. Unfortunately, a couple of errors get in the way of successful
> compilation. The first is that a number .tfm files produce the error: "Font
> xxxx not loadable: Bad metric (TFM) file". The second is that some files that
> pass this first test, throw a second error when compiled by themselves:
> "mktexpk: don't know how to create bitmap font for xxxx"
>
> What I would like is some sort of condition that tests to see if the font can
> be loaded and created. If it can, the test text is written in the font. If it
> can't, a message saying so is printed to the document. Any advice towards this
> end would be much appreciated.

You could do the testing in the R part of the process, with something
like:

check.font <- function (font) {
if(system(paste("pdftex -halt-on-error \\\\font\\\\test=", font, "\\\\end", sep=""), ignore.stderr=T, ignore.stdout=T)) {
whine(font)
} else {
include.font(font)
}
}

where, of course, “whine()” and “include.font()” are properly defined.
It will take a little bit of time, though, so it’s probably a good
idea to have “include.font()” write good fonts to some external file
so you don’t repeat yourself (and you’re not forced to do all the
testing in one go), and perhaps then you create your TeX file with all
those fonts.

(I’m slightly surprised you’re using R for this job, but that’s what
you’ve said, so I’ve used it too; anyway this can be accommodated in
any language.)

Best,
Paul