I've been using the fontspec package with XeTeX to load fonts. Here is a simple example that doesn't work:
\documentclass[12pt,a4paper]{book}
\usepackage{fontspec}
\begin{document}
\setmainfont{Latin Modern Mono}
\end{document}
This works fine on Windows and Linux (on Linux I had to update my FontConfig settings). On MacOS with MacTeX I get this error:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "Latin Modern Mono" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................
l.4 \setmainfont{Latin Modern Mono}
If I copy the font file to ~/Library/Fonts like this:
cp /usr/local/texlive/2017/texmf-dist/fonts/opentype/public/lm/lmmono12-regular.otf ~/Library/Fonts/
It fixes the problem, however that is not ideal for my situation because other users use this set up and I don't want them to have to worry about copying fonts around, especially since the fonts are already existing in the texlive directory. My understanding is that XeTeX searches both the macOS font folders and the texlive installation folders (http://mactex-wiki.tug.org/wiki/index.php/Font_Selection#Using_fonts_with_XeTeX).
How does fontspec resolve fonts on MacOS? Does MacTeX use FontConfig on MacOS or something else?
I have FontConfig installed on my Mac for other reasons, is this an issue?
System Information:
macOS 10.13.1 - 2011 Macbook Air
XeTeX 3.14159265-2.6-0.99998 (TeX Live 2017)
/usr/local/texlive/2017/fonts/opentype
andtruetype
in the/Library/Fonts
folder, keeping an eye when I update TeX Live. Tedious, but effective.\setmainfont{Latin Modern Mono}
on my Mac-based system: macOS 10.13.1 "High Sierra", TeXLive2017, XeTeX 3.14159265-2.6-0.99998, LaTeX2e <2017-04-15>, fontspec 2017/11/09 v2.6g. The OpenType font file that's used is/usr/local/texlive/2017/texmf-dist/fonts/opentype/public/lm/lmmono10-regular.otf
. Please tell us more about your TeX distribution.~/Library/Fonts
. They point to/Library/TeX/Root/texmf-dist/fonts/opentype
and/Library/TeX/Root/texmf-dist/fonts/truetype
respectively. It works.