I have some .ttf
fonts in ~/Library/Fonts
that I would like to use with XeLaTeX, but it can't seem to find them. For example, this will compile:
\documentclass[]{article}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\begin{document}
The quick brown fox jumps over the lazy dog.
\end{document}
But this won't:
\documentclass[]{article}
\usepackage{fontspec}
\setmainfont{Times New Roman.ttf}
\begin{document}
The quick brown fox jumps over the lazy dog.
\end{document}
And yes, Times New Roman.ttf
is in ~/Library/Fonts
.
Best Answer
You seem to have a misunderstanding of font lookup of
xetex
. The different lookup mechanisms are described in detail in the XeTeX manual, but I will try to boil things down a little for an answer.If you provide a font name, e.g. Times New Roman, as in your first example, where you call
then XeTeX will use your system's font utility to lookup the font. On GNU/Linux this is usually
fontconfig
. XeTeX will say tofontconfig
“Where is the font with the name «Times New Roman»?”, andfontconfig
will reply something like “It is located in.fonts/Times New Roman/Times New Roman.ttf
.” Then XeTeX will proceed to callxdvipdfm
which loads the font from that file.If you provide a file name instead of a font name, e.g.
Times New Roman.ttf
, as inthen XeTeX will immediately hand over to the
xdvipdfm
utility to include the font from that file, i.e. either fromTimes New Roman.ttf
in the current directory or viakpathsea
from thetexmf
tree.It is advisable to install fonts as system fonts, such that you don't have multiple copies of a font floating around your directories. If this is not possible for whatever reason then you should place the font files alongside your document in the same directory or maybe, if you use many fonts, in a subfolder solely dedicated to fonts. You may then load the fonts by their relative paths, as in
N.B.: I don't like spaces in file names, because some pieces of software tend to break if you don't escape them properly.