[XeTeX] Test for font presence

Mojca Miklavec mojca.miklavec.lists at gmail.com
Tue May 10 19:15:00 CEST 2011


On Mon, May 9, 2011 at 18:28, Ron Aaron wrote:
> Hi all -
>
> Is there a way to test -- from within a XeTeX document -- for the
> presence of a font, without causing the run to fail if the font doesn't
> exist?

There is a parameter
    \suppressfontnotfounderror
that you probably want to set to 1 and then reset to zero (or previous
value) again.


Here's Jonathan's example:

\def\checkforfont#1{\begingroup \suppressfontnotfounderror=1
 \font\test="#1" \relax
 \ifx\test\nullfont \message{Font "#1" was not found}
 \else \message{Font "#1" is available}\fi
 \endgroup}

\checkforfont{Times Roman}
\checkforfont{Lucida Grande}
\checkforfont{cmr12}
\checkforfont{Mistyped Name}

\end

A few examples also exist in font-xtx.mkii file in ConTeXt sources
(for example \doiffoundXTXfontelse).

Mojca


More information about the XeTeX mailing list