🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #437

How to ask in TeX whether a TFM exists?

#437
From: Geoffrey Tobin
Date: Sun, 26 Jul 1992 09:41
69 lines
2824 bytes
In Thomas Leathrum's very handy "mfpic" package, I'd like to test for
the prior existence of a "\graph" font's TFM file, "foo.tfm".  If it
doesn't exist, then I'd like to set the "\graph" font to "dummy.tfm".

The original macros contain the code

    \font\graph=#1

where #1 is replaced by "foo".  (Trust me, it is.)

Later \graph is used as follows

    {\graph \char\code}

The purpose of running TeX is at first to output code to a Metafont
file, so that "foo.mf" can be created.  So, in the first run of TeX,
"foo.tfm" doesn't exist yet, so TeX (C version 3.0) _hangs_.  (Isn't
that a bug?  Don?  Karl?)

So I tried the following to substitute "dummy" for "foo" if the latter
is absent:

    \openin\tfmfile=#1.tfm%
    \ifeof\tfmfile\font\graph=dummy%
    \else\font\graph=#1\fi%
    \closein\tfmfile

Works great when "foo.tfm" is absent,
but still loads "dummy.tfm" when "foo.tfm" is present!

Once I've got "foo.tfm", the original "\font\graph=#1" loads "foo.tfm",
so I'm puzzled!

I knew that `The TeXbook' says that "\immediate" is needed in such
situations for "\openout", but that it doesn't say so for "\openin".
But I know that finding info in `The TeXbook' is like looking for a
needle in a haystack, so I tried it all the same:

    \immediate\openin\tfmfile=#1.tfm%

etc.  Still fails.

Hmm, maybe TeX's "\ifeof" thinks that every _binary_ file is always
at "eof".  True or false?

So how does the poor user ask TeX to check whether a (TFM) file
exists?

Also, is there a way to ask TeX to check whether a character with a
particular _code_ is present in a (TFM) font file?

Alternatively, is there some other way to rewrite Thomas Leathrum's
"mfpic.tex" macros so that they _reliably_ (mark that word) tell TeX
to ignore the "\graph" font in the first run, but to use it in the
second run?

Yes, we can write two different copies of "mfpic.tex", one for the
first run, one for the second.  Another `dodge' is to copy "dummy.tfm"
or some other font to the name of "foo.tfm", which will be overwritten
by Metafont in time for the second run of TeX.  But, somehow, dodges
don't appeal.  Also, in the long run, an accumulation of dodges make
a system unusable.

Someone please be kind enough to help, sehr bitte, s'il vous plait.

Muchas Gracias! (sp?)
(Hope the gentle readers are not all at Barcelona!)

Geoffrey Tobin
Technical Details
Message-ID: <1992Jul26.094106.29604@lugb.latrobe.edu.au>
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!ariel!ucsvc.ucs.unimelb.edu.au!lugb!luxor.latrobe.edu.au!ecsgrt

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!ariel!ucsvc.ucs.unimelb.edu.au!lugb!luxor.latrobe.edu.au!ecsgrt
From: ecsgrt@luxor.latrobe.edu.au (Geoffrey Tobin)
Newsgroups: comp.text.tex
Subject: How to ask in TeX whether a TFM exists?
Message-ID: <1992Jul26.094106.29604@lugb.latrobe.edu.au>
Date: 26 Jul 92 09:41:06 GMT
Sender: news@lugb.latrobe.edu.au (USENET News System)
Organization: La Trobe University
Lines: 69