[XeTeX] Checking if a font exists
Heiko Oberdiek
heiko.oberdiek at googlemail.com
Mon Aug 30 09:25:04 CEST 2010
On Sun, Aug 29, 2010 at 10:55:10PM +0100, Philip Taylor (Webmaster, Ret'd) wrote:
> Grzegorz Murzynowski wrote:
>
> >And when the 18th output is on (writing to shell), you can put
> >
> >\immediate\write 18{fc-list "Myriad Pro" > fontcheck.tex}
> >\newread\fontcheck
> >\immediate\openin\fontcheck="fontcheck.tex"
> >\ifeof \fontcheck ???
>
> Is the "\immediate" necessary before the \openin at line 3 ?
No. (But it doesn't any harm either.)
There are lots of other problems (apart from the question,
whether fc-list is the correct test):
* \write18 might be disabled, then the write line isn't executed.
At least this can be tested by \pdfshellescape
(0 is disabled, 1 is unrestricted enabled, 2 is restricted enabled)
* \write18 can be enabled, but restricted (\pdfshellescape is 2).
The command might not be part of the allowed program list.
There is no way to test it except trying the feature.
* fontcheck.tex is generated in the current directory.
However it can be read from a different directory, depending
on the TeX configuration (TEXINPUTS, ...).
Especially problematic if \write18 is not enabled and the
existence of the file is used as check, whether the \write18
line has worked.
This can be cured by the pipe feature:
\openin\fontcheck "|fc-list 'Myriad Pro'"
Does it (especially the single quotes) work in Windows?
* A first line is also read, if the file is empty.
The macro that stores the line contains the character,
configured by \endlinechar and is empty if \endlinechar=-1.
* ...
Yours sincerely
Heiko Oberdiek
More information about the XeTeX
mailing list