I would like to distribute a class that uses a professional font loaded via fontspec, and falls back to one of the default fonts in TeX Live if this is not available. I know that one can detect fonts packaged with TeX Live:
\documentclass{article}
\usepackage{fontspec}
\IfFileExists{tgpagella.sty}{\setmainfont{TeX Gyre Pagella}}{}
\begin{document}
\fontname\font\ at \the\fontdimen6\font
\end{document}
This doesn't work, however, if one instead tries to detect a font file in the same directory:
\documentclass{article}
\usepackage{fontspec}
\IfFileExists{texgyrepagella-regular.otf}{\setmainfont{TeX Gyre Pagella}}{}
\begin{document}
\fontname\font\ at \the\fontdimen6\font
\end{document}
Is there a mechanism somewhere to include .otf
files in what \IfFileExists
is able to detect?
\fontspec_font_if_exist:nTF
and similar commands look to be the right thing.... – David Carlisle Jan 21 '19 at 16:43\IfFontExistsTF
. – Ulrike Fischer Jan 21 '19 at 16:44_
and:
– David Carlisle Jan 21 '19 at 16:45_
and:
;-). – Ulrike Fischer Jan 21 '19 at 16:47