1

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)

  • I usually copy the fonts in /usr/local/texlive/2017/fonts/opentype and truetype in the /Library/Fonts folder, keeping an eye when I update TeX Live. Tedious, but effective. – egreg Nov 10 '17 at 18:40
  • I experience no problem with \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. – Mico Nov 10 '17 at 21:42
  • I put in my system specifications above. How did you get the fontspec version information? – jdw Nov 11 '17 at 2:46
  • For usage with XeTeX I add two symlinks inside ~/Library/Fonts. They point to /Library/TeX/Root/texmf-dist/fonts/opentype and /Library/TeX/Root/texmf-dist/fonts/truetype respectively. It works. – user4686 Nov 11 '17 at 10:42
  • XeTeX does not use fontconfig on Mac systems. It uses the system API. – user4686 Nov 11 '17 at 10:45
1

It appears this is a case of RTFM (http://ctan.mirrors.hoobly.com/macros/latex/contrib/fontspec/fontspec.pdf). According to the latest fontspec documentation this isn't possible with XeTeX without copying the fonts to ~/Library/Fonts.

XeTeX and LuaTEX also allow fonts to be loaded by file name instead of font name. When you have a very large collection of fonts, you will sometimes not wish to have them all installed in your system’s font directories. In this case, it is more convenient to load them from a different location on your disk. This technique is also necessary in XeTeX when loading OpenType fonts that are present within your TEX distribution, such as /usr/local/texlive/2013/texmf- dist/fonts/opentype/public. Fonts in such locations are visible to XeTeX but cannot be loaded by font name, only file name; LuaTEX does not have this restriction.

  • no it IS possible without copying the fonts. See my comment above. – user4686 Nov 11 '17 at 10:44
  • 1
    I tried your symlinks, they did not work for me. Can you load the "Latin Modern Mono" font with your set up? – jdw Nov 14 '17 at 16:11
  • moved my comment to an answer – user4686 Nov 14 '17 at 18:01
0

I have been using for some time symlinks in my ~/Library/Fonts. Here is a view of that repertory from Emacs:

enter image description here

Then, consider test document

\documentclass[12pt,a4paper]{book}
\usepackage{fontspec}
\XeTeXtracingfonts1
\setmainfont{Latin Modern Mono}
\begin{document}
Hello
\end{document}

It produces expected result, and the log file contains things like

Requested font "Latin Modern Mono" at 12.0pt
 -> /Users/xXx/Library/Fonts/TeXOpenType/public/lm/lmmono12-regular.otf
Requested font "Latin Modern Mono/OT" at 12.0pt
 -> /Users/xXx/Library/Fonts/TeXOpenType/public/lm/lmmono12-regular.otf
\g__fontspec_family_LatinModernMono_int=\count180
Requested font "Latin Modern Mono/OT" at 12.0pt
 -> /Users/xXx/Library/Fonts/TeXOpenType/public/lm/lmmono12-regular.otf
Requested font "Latin Modern Mono/BI/OT" at 12.0pt
 -> /Users/xXx/Library/Fonts/TeXOpenType/public/lm/lmmono10-italic.otf
Requested font "Latin Modern Mono/OT" at 12.0pt
 -> /Users/xXx/Library/Fonts/TeXOpenType/public/lm/lmmono12-regular.otf
Requested font "Latin Modern Mono/B/OT" at 12.0pt
 -> /Users/xXx/Library/Fonts/TeXOpenType/public/lm/lmmono12-regular.otf
.................................................
. fontspec info: "no-font-shape"
. 
. Could not resolve font "Latin Modern Mono/B" (it probably doesn't exist).
.................................................
Requested font "Latin Modern Mono/OT" at 12.0pt
 -> /Users/xXx/Library/Fonts/TeXOpenType/public/lm/lmmono12-regular.otf
Requested font "Latin Modern Mono/I/OT" at 12.0pt
 -> /Users/xXx/Library/Fonts/TeXOpenType/public/lm/lmmono10-italic.otf
Requested font "Latin Modern Mono/OT" at 12.0pt
 -> /Users/xXx/Library/Fonts/TeXOpenType/public/lm/lmmono12-regular.otf
Requested font "Latin Modern Mono/OT" at 12.0pt
 -> /Users/xXx/Library/Fonts/TeXOpenType/public/lm/lmmono12-regular.otf
Requested font "Latin Modern Mono/I/OT" at 12.0pt
 -> /Users/xXx/Library/Fonts/TeXOpenType/public/lm/lmmono10-italic.otf
Requested font "Latin Modern Mono/I/OT" at 12.0pt
 -> /Users/xXx/Library/Fonts/TeXOpenType/public/lm/lmmono10-italic.otf
Requested font "Latin Modern Mono/BI/OT" at 12.0pt
 -> /Users/xXx/Library/Fonts/TeXOpenType/public/lm/lmmono10-italic.otf
Requested font "Latin Modern Mono/BI/OT" at 12.0pt
 -> /Users/xXx/Library/Fonts/TeXOpenType/public/lm/lmmono10-italic.otf
.................................................
. fontspec info: "defining-font"
. 
. Font family 'LatinModernMono(0)' created for font 'Latin Modern Mono' with
. options [Ligatures=TeX].
.  
.  This font family consists of the following NFSS series/shapes:
.  
. - 'normal' (m/n) with NFSS spec.: <->"Latin Modern
. Mono/OT:script=latn;language=DFLT;mapping=tex-text;"
. - 'small caps'  (m/sc) with NFSS spec.: 
. - 'italic' (m/it) with NFSS spec.: <->"Latin Modern
. Mono/I/OT:script=latn;language=DFLT;mapping=tex-text;"
. - 'italic small caps'  (m/itsc) with NFSS spec.: 
. - 'bold italic' (bx/it) with NFSS spec.: <->"Latin Modern
. Mono/BI/OT:script=latn;language=DFLT;mapping=tex-text;"
. - 'bold italic small caps'  (bx/itsc) with NFSS spec.: 
.................................................
LaTeX Info: Redefining \rmfamily on input line 4.
Requested font "Latin Modern Mono/OT:script=latn;language=DFLT;mapping=tex-text
;" at 12.0pt
 -> /Users/xXx/Library/Fonts/TeXOpenType/public/lm/lmmono12-regular.otf

By the way, this does not perturbate recent luaotfload: the LuaTeX database will not contain duplicate entries as it was the case perhaps two years ago (i.e. in 2015). I forgot the details.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.