[Tex/LaTex] How are font names chosen for LuaLaTeX and XeLaTeX

fontsfontspecluaotfloadluatexxetex

I've installed a ttf version of Adobe Garamond Pro on my computer (a Mac) using the Font Book application. The font files are in /Library/Fonts/. I'm wondering how XeLaTeX and LuaLaTeX end up picking the names by which you can refer to the font. The following MWE will compile with XeLaTeX but not LuaLaTeX for me:

\documentclass{article}

\usepackage{fontspec}
\setmainfont
  [
    Ligatures={
      TeX,
      Common
    },
    BoldFont={* Semibold}
  ]
  {Adobe Garamond Pro} 

\begin{document}

asdf \textbf{asdf}

\end{document}

If I try to compile with LuaLaTeX, I get the following error:

Users/adamliter/Library/texlive/2017/texmf-var/luatex-cache/generic/fonts/otl/adobe-garamond-pro-italic-2009.luc)
luaotfload | resolve : sequence of 3 lookups yielded nothing appropriate.

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

l.20   {Adobe Garamond Pro}

(I believe, however, that there was a point in time—perhaps with TeX Live 2015 or 2016—where I could have compiled that MWE with LuaLaTeX, based on old .tex documents that I have on my computer.)

However, the following MWE does compile with LuaLaTeX (and also XeLaTeX):

\documentclass{article}

\usepackage{fontspec}
\setmainfont
  [
    Ligatures={
      TeX,
      Common
    },
    BoldFont={AGaramondPro-Semibold}
  ]
  {AGaramondPro-Regular}

\begin{document}

asdf \textbf{asdf}

\end{document}

Though it isn't that big of a deal, I do find this is a bit annoying. I'd like to be able to make use of fontspec's ability to specify variants with *. But, with LuaLaTeX at least, it seems that I can only refer to the Semibold variant of Adobe Garamond Pro as AGaramondPro-Semibold, which precludes me from being able to specify the bold variant as Semibold using *.

(Oddly, it seems that I can refer to AGaramondPro-Regular as Adobe Garamond Pro when using LuaLaTeX. In other words, if I delete the BoldFont key-value pair in the first MWE, it compiles with LuaLaTeX just fine.)

Thus, I'm wondering how exactly LuaLaTeX chooses the names by which I can refer to fonts. Is it something about the .ttf files? Is there anything I can do to be able to get the first MWE to compile with LuaLaTeX?

Best Answer

Fonts can be found by its symbolic name(s) or file name. By a symbolic name is only possible if the font is saved in a font directory where the system will search for fonts, e.g. /Library/fonts/. The symbolic names can be listed with the help of otfinfo:

voss@shania:~/.fonts/GaramondPro$ otfinfo -i AGaramondPro-Regular.otf 
Family:              Adobe Garamond Pro
Subfamily:           Regular
Full name:           AGaramondPro-Regular
PostScript name:     AGaramondPro-Regular
[...]

or

voss@shania:~/.fonts/GaramondPro$ otfinfo -i AGaramondPro-Semibold.otf 
Family:              Adobe Garamond Pro
Subfamily:           Bold
Full name:           AGaramondPro-Semibold
PostScript name:     AGaramondPro-Semibold
Preferred subfamily: Semibold
Mac font menu name:  Adobe Garamond Pro Sb
[...]

The following example uses these symbolic names:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{AGaramondPro}[
  UprightFont = *-Regular,
  BoldFont = *-Semibold]
\begin{document}

    asdf \textbf{asdf}

\end{document}

Using filenames is also possible.

\setmainfont{Adobe-Garamond-Pro}[
  Extension=.ttf,
  Path=..., % only for non system font directories needed
  UprightFont = *-Regular_2008,
  BoldFont = *-Bold_2008,
  [...]]

If all symbolic fontnames of a family are consistent then a

\setmainfont{AGaramondPro}

should be enough; fontspec will find all other sub families, like regular, bold, italic, a.s.o.

Related Question