I want to include fonts in a /include/fonts/ directory alongside my foo.tex doc, so I don't have to install the fonts to the system. I can successfully use this to get that working:


However it's a pain to have to specify all of the variations manually, when fontspec has built in smarts to do this when using a font name (instead of font file name). Is there any way to get the best of both worlds: to be able to keep the fonts in a directory relative to the .tex file, but for fontspec to automatically figure out all the variations for itself?

So really, in a perfect world I just want to be able to use the following, and for fontspec to find all the variants for itself (note I use the font name here, not file name):

]{OFL Sorts Mill Goudy}

Here's a full example, FWIW:

% This works only if the font file is named OFLGoudyStM.otf
% and in the current path. Contrary to docs, TEXINPUTS is not searched.
% Also, the different variants like italic can no longer be automatically
% inferred and need to be explicitly specified
% \setmainfont[
%   ExternalLocation,
% ]{OFLGoudyStM}
% This will find the system font
\setmainfont{OFL Sorts Mill Goudy}


\LARGE{This is some \textit{text.}}
  • 2
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Aug 26 '14 at 15:07
  • I speculate that where the font is installed in the system, fontspec is able to use the system APIs to get the font and all its variants by just the single name. However when the font is not a system font, it doesn't have those APIs available so can only work on a file by file basis. If that's how it works, then the answer will be that no, I can't have the perfect world that I wanted, and I will have to manually specify all variants. – Sam Carr Aug 26 '14 at 15:59
  • 1
    The Kerkis OpenType font family has Kerkis.otf, Kerkisitalics.otf, Kerkisbold.otf and Kerkisbolditalics.otf. Linux Libertine has LinLibertine_R.otf, LinLibertine_RI.otf, LinLibertine_RB.otf and LinLibertine_RBI.otf. Other font families have even different name schemes; which ones should fontspec test? – egreg Aug 28 '14 at 15:45
  • @egreg He wants to test not some names in particular, but the same that are checked when the font is installed in the system. – Manuel Aug 28 '14 at 16:12
  • At least on Linux, you should be able to install the fonts under the ~/.fonts subdirectory. ETA: The fontspec documentation says, “Fonts selected by filename must include bold and italic variants explicitly.” So, if you meant a subdirectory of the current folder, that does not seem to be possible. – Davislor Sep 2 '14 at 3:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.