# \setmainfont works with XeTeX but not with LuaTeX

I'm trying to use LuaTeX with Adobe's Garamond Premier Pro, but it doesn't work, saying that:

! error:  (type 0): cannot find file ''
!  ==> Fatal error occurred, no output PDF file produced!


while XeTeX compiles fine.

I managed to narrow down the issue to the following code:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Garamond Premier Pro}
\begin{document}
hello
\end{document}


I'm using TeXLive 2018.

Following Ulrike's suggestion, I changed the font name by the file name:

\documentclass{article}
\usepackage{fontspec}
% \setmainfont{Garamond Premier Pro}
\setmainfont{GaramondPremrPro.otf}
\begin{document}
hello
\end{document}


this didn't work as well :/

So I tried copying GaramondPremrPro.otf from the installed directory ($HOME/.local/share/fonts/) to the current directory, then it worked (it also works if I put them in a directory in the texmf tree). So I guess that the problem is with Ubuntu's font directory... Addendum: Something I think it's odd... Suppose I have only the file GaramondPremrPro.otf in the current directory and call the font by the file name: \documentclass{article} \usepackage{fontspec} % \setmainfont{Garamond Premier Pro} \setmainfont{GaramondPremrPro.otf} \begin{document} hello \bfseries hello \end{document}  I get a only font substitution warning because LaTeX couldn't find the bold font file: LaTeX Font Warning: Font shape TU/GaramondPremrPro.otf(0)/bx/n' undefined (Font) using TU/GaramondPremrPro.otf(0)/m/n' instead on input line 7.  However, if I call the font by its name: \documentclass{article} \usepackage{fontspec} \setmainfont{Garamond Premier Pro} % \setmainfont{GaramondPremrPro.otf} \begin{document} hello \bfseries hello \end{document}  I get the cryptic cannot find file '' from above. If I remove the \bfseries instruction, both versions work. • It works for me. Oct 2, 2018 at 14:49 • If lualatex wouldn't find the font at all the error message would be different. What happens if you use the file name with extension (something like \setmainfont{xxx.otf})? Oct 4, 2018 at 7:04 • Have you tried \setmainfont{Garamond Premier Pro}[Path =$HOME/.local/share/fonts/]?
– Mico
Oct 4, 2018 at 14:05
• The update wouldn't change the way luaotfload searches fonts, it address some other problems. Search by font name is different in xelatex and lualatex. Do other fonts in this folder work? You could also check your font in the name database \texmf-var\luatex-cache\generic\names and check if there are other fonts with this name which could confuse luaotfload. Oct 4, 2018 at 14:13
• Just saw the edit: the behaviour with \bfseries means that fontspec can't really identify the corresponding bold font. That can happen (font names are sometimes odd) and you can resolve this by using the BoldFont option. Oct 4, 2018 at 14:16

/usr/local/texlive/2018/texmf-var/luatex-cache/generic/names/
/usr/local/texlive/2018/texmf-var/luatex-cache/generic/fonts/otl