Skip to content

Instantly share code, notes, and snippets.

@MatthewJA
Created November 5, 2016 03:06
Show Gist options
  • Save MatthewJA/6c6e30720e2325363f8f9180d9a2972f to your computer and use it in GitHub Desktop.
Save MatthewJA/6c6e30720e2325363f8f9180d9a2972f to your computer and use it in GitHub Desktop.
Hack to get cross-platform fallback fonts with XeLaTeX.
\suppressfontnotfounderror1
\def\myfont{Palatino} % Or whatever your primary font choice is.
\def\myfallback{Palatino Linotype} % Or whatever your fallback font is.
\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
\setmainfont[Ligatures=TeX]{\myfont}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment