[XeTeX] Checking if a font exists

Jonathan Kew jfkthame at googlemail.com
Mon Aug 30 09:22:53 CEST 2010


On 30 Aug 2010, at 05:56, Wilfred van Rooijen wrote:

> The (more dificult) solution could be to make a shell script which will run the compilation of the xelatex source and detect whether or not the run was succesfull - if not, change the input file to the other font and retry.

I'm surprised no-one has suggested the straightforward, pure-xetex approach: something along these lines (untested).....

  \def\myfont{"Myriad Pro"}
  \def\myfallback{"Arial"}
  \count255=\interactionmode
  \batchmode
  \font\foo=\myfont\space at 10pt
  \ifx\foo\nullfont
    \font\foo = \myfallback\space at 10pt
    \ifx\foo\nullfont
      \errorstopmode
      \errmessage{no suitable font found}
    \else
      \let\myfont=\myfallback
    \fi
  \fi
  \interactionmode=\count255
  % and now proceed to use \myfont.....

JK




More information about the XeTeX mailing list