[Tex/LaTex] fontspec font-not-found / Invalid fontname on Mac update

ebgaramondfontspecmacosxetex

Over the past few years, I have had a rare but recurring problem where, when I typeset a document using EB Garamond, which I have installed on my Mac, I receive the following error:

(/usr/local/texlive/2017/texmf-dist/tex/latex/fontspec/fontspec.cfg)))kpathsea:make_tex: Invalid fontname `EB Garamond', contains ' '
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "EB Garamond" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................

This occurs even with a bare-bones MWE, and it occurs with completely updated software. It seems to only affect fonts installed locally, that is, in /Users/moacir/Library/Fonts. An example of the system profiler description of two culprit fonts is at the bottom.

It does not occur when I call xelatex from TeXShop, even though TeXShop uses the exact same path to TeXLive. It also does not seem to occur with system fonts, by which I mean fonts installed in /System or /Library. For example, if I have sections in Helvetica Neue, they appear in the pdf. The sections in EB Garamond are blank.

It seems that restarting the Mac when the problem occurs solves it, but I would rather not have to restart my computer every time the problem occurs.

Here is a general timeline since I first asked about this question in December 2016:

  • XeLaTeX was working fine whenever I’d use it throughout early 2017. I kept up with MacOS updates, but did not install TeXLive 2017.
  • In mid-July, I used XeLaTeX to typeset an article I’m writing in EB Garamond. This is the last time I know I used the software from the command line.
  • In late July, I updated my computer to 10.12.6 (with restart).
  • On August 1, I start working on a new project involving TeX, and the error appears. I do not remember if I had used XeLaTeX since upgrading to 10.12.6.
  • On August 2, I publish the first version of this question.
  • I then update TeXLive to 2017 (vaguely thinking that solved the problem the last time I had it), and the problem continues.
  • I restart the computer and the problem goes away.
  • On August 4, the problem reappears. A restart makes it go away.
  • On August 5, the problem reappears. A restart makes it go away.

The four (including in 2016) times I had this problem, they were solved once “by magic” and three times by a restart. I wish I had a more useful solution, however, than either of these two.

Currently, the system is running fine.

MWE:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{EB Garamond}
\begin{document}
All human beings are born free and equal in dignity and rights.
\end{document}

Here are the font descriptions on my system both of two fonts that give trouble (HumboldtFraktur and EB Garamond):

EBGaramond.otf:

  Kind: OpenType
  Valid: Yes
  Enabled: Yes
  Location: /Users/moacir/Library/Fonts/EBGaramond.otf
  Typefaces:
    EBGaramond:
      Full Name: EB Garamond
      Family: EB Garamond
      Style: Regular
      Version: Version 000.010
      Unique Name: FontForge 2.0 : EB Garamond : 6-3-2011
      Copyright: Created by Georg Duffner with FontForge 2.0 (http://fontforge.sf.net)
      Outline: Yes
      Valid: Yes
      Enabled: Yes
      Duplicate: No
      Copy Protected: No
      Embeddable: Yes

HumboldtFraktur-Regular.ttf:

  Kind: TrueType
  Valid: Yes
  Enabled: Yes
  Location: /Users/moacir/Library/Fonts/HumboldtFraktur-Regular.ttf
  Typefaces:
    HumboldtFraktur:
      Full Name: HumboldtFraktur
      Family: HumboldtFraktur
      Style: Regular
      Version: Version 1.0; 2002; initial release
      Unique Name: TypographerMediengestaltung: HumboldtFraktur: 2002
      Designer: Dieter Steffmann
      Copyright: Copyright (c) Typographer Mediengestaltung, 2002. All rights reserved. Humboldt-Fraktur geschaffen von Hiero Rhode, 1938. Digitalisiert und ergaenzt durch Dieter Steffmann, Kreuztal.
      Description: Humboldt-Fraktur geschaffen von Hiero Rhode, 1938. Digitalisiert und ergaenzt durch Dieter Steffmann, Kreuztal.
      Outline: Yes
      Valid: Yes
      Enabled: Yes
      Duplicate: No
      Copy Protected: No
      Embeddable: Yes

Best Answer

Following the recommendation by @WillRobertson, it seems like the answer, for now, is to avoid using fontspec's font finding abilities and change the MWE to read:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{EBGaramond}[
  Path = /Users/moacir/Library/Fonts/,
  UprightFont = * ,
  ItalicFont = *12-Italic ,
  SmallCapsFont = *SC ,
  Extension = .otf
  ]
\begin{document}
  All human beings are born free and equal in dignity and rights.
\end{document}

Note that the settings for ItalicFont and SmallCapsFont are consistent with what EB Garamond offers.

Related Question