I'm working on a document with a collaborator who is particular about their choice of font. My collaborator has provided me with the font files, but on the particular machine I'm using then I don't have administrator access and can't install the font system-wide. I can, though, simply load the font explicitly through fontspec
(we're using lualatex
as the engine) but this means that our documents differ slightly since my collaborator loads it from the system and I load it from a file.
Can we make it so that one preamble works for both? I imagine it being to tell fontspec
to look for a particular font, and if it doesn't find it then to look for another one.
Note that this is about loading the whole font, not just for individual characters.
Some code to play with.
\documentclass{article}
\usepackage{fontspec}
% One person has this installed system-wide
\setmainfont{TeX Gyre Termes}
% Try misspelling the above and watch lualatex complain loudly about the missing font
% The other only has the file
\setmainfont{texgyretermes-regular.otf}
\begin{document}
Wouldn't it be nice if this were Termes?
\end{document}
(Note: This is a question that I know the answer to, and is actually an RTM, but I did spend a while fruitlessly searching online for an answer and didn't even get a hint that it was possible, so thought it worth posting here to improve search engine results. I'll wait before posting my answer because I'm lazy and someone else might post a better answer with nice code before I get round to it. Once an answer has been posted, I'll remove this note.)