[Tex/LaTex] fontspec error: “font-not-found” on Mac OS X

fontsfontspecmacxetex

I need to use some system fonts in my document, and I use fontspec and XeLaTeX to do so. I find the font name from fc-list, but when I compile it with XeLaTeX, there's a fontspec error:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
! 
! The font "Luxi Serif" cannot be found.
! 
! See the fontspec documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  

l.21 \setmainfont{Luxi Serif}

I just migrated from Linux to Mac OS X. Back when I was using Linux machine XeLaTeX works with system fonts. It seems on Mac fontspec can't find fonts from system directory.

fc-list|grep "Luxi Serif"

shows

/usr/X11R6/lib/X11/fonts/...
/opt/X11/share/fonts/...

I checked the permissions of directories and font files, nothing wrong.

There are many font directories on Mac, is it possible to allow the use of fonts in all the directories?

Best Answer

If you use the \setmainfont directive rather than a \fontspec directive, I believe it's necessary to specify the font by its system name rather than by the file name. E.g., Luxi Serif.

Assuming you've downloaded and activated all four fonts of the Luxi Serif font family, the following MWE shows how to load and make use of them.

% !TEX TS-program = xelatex
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Luxi Serif}
\newcommand\qbf{The quick brown fox jumps over the lazy dog.}
\begin{document}
\qbf

\emph{\qbf}

\textbf{\qbf}

\em\bfseries\qbf
\end{document}

enter image description here

Incidentally, Luxi Serif is not a system font -- at least not for MacOSX 10.7.x "Lion". If XeTeX (and LuaTeX) can't find this font, it's almost certainly the case that it wasn't activated in a way MacOS expects it to be activated. How did you obtain the fonts, and in which directory are they located right now?

One way to activate fonts correctly after you've downloaded them is to open a Finder window with the directory to which the fonts were downloaded, double-click on each of the font files in turn, and then to click on the "Install Font" button located in the lower right corner of the window that opens. The fonts you download and activate in this fashion will likely be stored in a folder called /Users/<username>/Library/Fonts, where <username> will be your login name on your system.