# How are font names chosen for LuaLaTeX and XeLaTeX?

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}
]

\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>.
!...............................................



(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?

• Hic sunt leones – egreg Sep 14 '17 at 15:04
• @egreg: I only knew Hic sunt dracones in French (if I may say so …). – Bernard Sep 14 '17 at 15:08
• @Bernard For some reasons, the former is more used in Italy, AFAIK. – egreg Sep 14 '17 at 15:10

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
Subfamily:           Bold
Full name:           AGaramondPro-Semibold
PostScript name:     AGaramondPro-Semibold
Preferred subfamily: Semibold
[...]


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.

• +1 Ha, thanks! :) I should have thought of this. Is there any chance you could say a bit about how these names are determined by LuaLaTeX and XeLaTeX. I'm also somewhat curious how this works? – Adam Liter Sep 14 '17 at 17:08
• see edited answer ... – user2478 Sep 14 '17 at 17:54

You can use (with lualatex) this in your example:

\documentclass{article}

\usepackage{fontspec}
\setmainfont
[
Ligatures={
TeX,
Common
},
UprightFont={*regular},
BoldFont={*semibold}
]
{agaramondpro}

\begin{document}

asdf \textbf{asdf}

\end{document}


But imho the *-versions are not really worth the time invested. Every font family seems to have its own system. It is faster to write the full font name down.

• +1, Thanks. :) Interestingly then, this won't compile with XeLaTeX ... Do you know if there is any possibility that works for both? – Adam Liter Sep 14 '17 at 16:00
• file names normally should work for both. – Ulrike Fischer Sep 14 '17 at 16:34
• LuaTeX (it uses luaotfload) converts all file names to lowercase, but XeTeX (it uses fontconfig) doesn't. So LuaTeX finds the fonts and XeTeX not. – user2478 Sep 14 '17 at 16:34
• @UlrikeFischer: the file names are AGaramond-Regular.otf a.s.o. – user2478 Sep 14 '17 at 16:36
• @Herbert: My code above doesn't use file names but fontnames. But it is quite possible that xelatex can't use them. – Ulrike Fischer Sep 14 '17 at 16:39