There is one important difference between the font handling in LuaLaTeX and XeLaTeX:
While LuaLaTeX allows you to access all your fonts by file name or font name, XeLaTeX restricts this:
- System fonts in your system font directory (the fonts visible to other programs) can only be called by the font name (like "TeX Gyre Termes").
- Fonts installed in the TeX directories can only be called by their file names.
Now installing tex-gyre through TeX Live installs the font in the TeX directories, so you have to use the file name.
If accessing the font by font name is really important to you, you could either add the TeX font path to your system font path or use LuaTeX.
But this would not be very portable, so we want to use file names instead.
You could specify the filename in fontspec, but there is no need for fontspec here.
You just need a NFSS font definition for the font:
Save the following file under the name tutgtermes.fd (in your texmf-local directory for a system-wide install or in your document path)
\ProvidesFile{tutgtermes.fd}[2019/01/17 v0.0 OpenType font definitions for TeX Gyre Termes]
\DeclareFontFamily{TU}{tgtermes}{}
\DeclareFontShape{TU}{tgtermes}{m}{n}{%
<->\UnicodeFontFile{texgyretermes-regular}{\UnicodeFontTeXLigatures}
}{}
\DeclareFontShape{TU}{tgtermes}{m}{it}{%
<->\UnicodeFontFile{texgyretermes-italic}{\UnicodeFontTeXLigatures}
}{}
\DeclareFontShape{TU}{tgtermes}{m}{sc}{%
<->\UnicodeFontFile{texgyretermes-regular}{\UnicodeFontTeXLigatures +smcp}
}{}
\DeclareFontShape{TU}{tgtermes}{m}{scit}{%
<->\UnicodeFontFile{texgyretermes-italic}{\UnicodeFontTeXLigatures +smcp}
}{}
\DeclareFontShape{TU}{tgtermes}{b}{n}{
<->\UnicodeFontFile{texgyretermes-bold}{\UnicodeFontTeXLigatures}
}{}
\DeclareFontShape{TU}{tgtermes}{b}{it}{%
<->\UnicodeFontFile{texgyretermes-bolditalic}{\UnicodeFontTeXLigatures}
}{}
\DeclareFontShape{TU}{tgtermes}{b}{sc}{
<->\UnicodeFontFile{texgyretermes-bold}{\UnicodeFontTeXLigatures +smcp}
}{}
\DeclareFontShape{TU}{tgtermes}{b}{scit}{%
<->\UnicodeFontFile{texgyretermes-bolditalic}{\UnicodeFontTeXLigatures +smcp}
}{}
\DeclareFontShape{TU}{tgtermes}{bx}{n}{%
<->ssub * tgtermes/b/n
}{}
\DeclareFontShape{TU}{tgtermes}{bx}{it}{%
<->ssub * tgtermes/b/it
}{}
\DeclareFontShape{TU}{tgtermes}{bx}{sc}{%
<->ssub * tgtermes/b/sc
}{}
\DeclareFontShape{TU}{tgtermes}{bx}{scit}{%
<->ssub * tgtermes/b/scit
}{}
\endinput
Now LaTeX knows all TeX Gyre Termes shapes as the family tgtermes (with encoding TU aka Unicode).
You can use the font with
\documentclass{article}
\renewcommand\rmdefault{tgtermes}
\renewcommand\bfdefault{b}
\begin{document}
\end{document}
If you really want to use fontspec, you could instead give fontspec a hint where to find the fonts: Create a file named texgyretermes.fontspec with
\defaultfontfeatures[TeX Gyre Termes]
{
Extension = .otf ,
UprightFont = texgyretermes-regular,
BoldFont = texgyretermes-bold,
ItalicFont = texgyretermes-italic,
BoldItalicFont = texgyretermes-bolditalic,
}
Then fontspec finds the font:
\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}
\begin{document}
\end{document}
The last version is quite fragile and might break if you change anything in the name.