# [XeTeX] Checking if a font exists

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}
> >\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: