# How to install font Tex Gyre Termes

I installed TexLive 2018 from https://www.tug.org/texlive/quickinstall.html

Consider this script:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Tex Gyre Termes}
\begin{document}
\end{document}


When I compile it with xelatex I get:

(/usr/local/texlive/2018/texmf-dist/tex/latex/fontspec/fontspec.cfg)))kpathsea:make_tex: Invalid filename Tex Gyre Termes', contains ' '

! Package fontspec Error: The font "Tex Gyre Termes" cannot be found.


I try to add package tex-gyre in Ubuntu:

sudo su
root@v-VirtualBox:/home/v# export PATH=\$PATH:/usr/local/texlive/2018/bin/x86_64-linux/
root@v-VirtualBox:/home/v# which tlmgr
/usr/local/texlive/2018/bin/x86_64-linux//tlmgr
root@v-VirtualBox:/home/v# tlmgr install tex-gyre
tlmgr: package repository http://mirror.datacenter.by/pub/mirrors/CTAN/systems/texlive/tlnet (verified)
tlmgr install: package already present: tex-gyre


I have a lot of tex-gyre files in the directory /usr/share/texmf/fonts/opentype/public/tex-gyre/. There are also many .otfs in /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/tex-gyre/. Furthermore, it is available in Libre Office:

Why is it not accessible to xelatex?

** Why is the font Tex Gyre Termes missing and how to install it? **

Update

Once I download the .zip from http://www.gust.org.pl/projects/e-foundry/tex-gyre/termes/qtm2.004otf.zip how and where exactly do I install the .otf files?

Solution

The problem was resolved by changing

\setmainfont{Tex Gyre Termes}


to

\setmainfont{TeX Gyre Termes}

• Does it work when you capitalize the X in TeX? – Davislor Jan 17 at 14:58

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.

You should be able to install all the TeX Gyre fonts using tlmgr, as you did:

tlmgr install tex-gyre


If that doesn't work, you can always download the fonts from the website and install them as normal fonts, which should allow fontspec to find them.

As your log appears to be complaining about a space, have you tried removing it? This certainly works for me:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeXGyreTermes}
\begin{document}
test
\end{document}
`