13

I recently started using XeLaTeX on Mac OSX, and was not able to get XeLaTeX to recognize the fonts that I had installed. After opening Font Book, bringing up the Preferences dialog, and opting to install the fonts into the system-level directory (/System/Library/Fonts) instead of the user-level directory (~/Library/fonts), everything worked well.

However, I prefer not to mix the fonts that I download with the fonts that come with the operating system. In the future, I may also wish to have XeLaTeX use fonts in arbitrary directories on my system (say, some subdirectory within a local Git repository). I am very naively guessing that the reason XeLaTeX is not finding my user-level fonts is that they are not in the OS font cache. However, invoking fc-cache on my user-level font directory still does not update the output I get from fc-list with my User fonts.

So, here's my question: how can I get XeLaTeX to use TTF and OTF fonts located in arbitrary directories on my system? Currently, I can only get XeLaTeX to work with System fonts.

Thank you for your insight!

2 Answers 2

13

fontspec allows setting a path to specific fonts which are not in the current search path (or installed system-wide). This example uses SpecialFont.ttf just after downloading it:

% !TEX TS-program = XeLaTeX
\documentclass[a4paper]{article}

\usepackage{fontspec,lipsum}

\setmainfont[Path=/Users/username/Downloads/]{SpecialFont.ttf}

\begin{document}
\lipsum
\end{document} 
1
  • Exactly what I was looking for -- thanks a bunch! Commented Sep 6, 2012 at 15:33
1

@hakaze's answer helped me a lot. I still needed to add some parameters so that every variation can be found:

\setmainfont{LibertinusSerif}[Path = input/fonts/,
                              Extension = .otf,
                              UprightFont = *-Regular,
                              BoldFont = *-Bold,
                              ItalicFont = *-Italic,
                              BoldItalicFont = *-BoldItalic,
                              Ligatures=TeX
                             ]

as described in fontspec's documentation.

The input/fonts/ folder contains:

LibertinusSerif-BoldItalic.otf
LibertinusSerif-Bold.otf
LibertinusSerifDisplay-Regular.otf
LibertinusSerifInitials-Regular.otf
LibertinusSerif-Italic.otf
LibertinusSerif-Regular.otf
LibertinusSerif-SemiboldItalic.otf
LibertinusSerif-Semibold.otf

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .