# Using the TeX Live fonts in xelatex

If one have installed the Vanialla TeX Live 2015 (i.e. by hand not via packages) on Ubuntu. An MWE like this does not compile with xelatex

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{TeX Gyre Pagella}
\begin{document}

Hello, World!

\end{document}


Eventhough TeX Gyre Pagella opentype is a part of TL15.

XeLaTeX will look in the font cache for fonts to use with fontspec. So even if a font is found in TL the font cache might not find it.

On linux at least the TL fonts may not be be automatically included into the font cache.

How do we solve this?

• This isn't a question.... At least, I can figure out the question but it would be clearer to just ask it! – cfr Jul 27 '15 at 12:57
• @cfr, changed ;-) – daleif Jul 27 '15 at 14:53

Here is how I solved it.

Basics: Ubuntu Linux. Manually installed TeX Live 2015 (from http://tug.org/texlive).

1. TeX Live already come with the needed configuration file. It is found in

<path to TL15>/texmf-var/fonts/conf/texlive-fontconfig.conf

2. Copy this to /etc/fonts/conf.d/09-texlive-fonts.conf:

sudo cp <path to TL15>/texmf-var/fonts/conf/texlive-fontconfig.conf /etc/fonts/conf.d/09-texlive-fonts.conf

3. Now update the font cache via

sudo fc-cache -fsv


Now this MWE run just fine for me (compiles using xelatex)

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{TeX Gyre Pagella}
\begin{document}

Hello, World!

\end{document}


(feel free to enhance this answer)

• The newest command is \setmainfont, the old \setromanfont only works because of backwards compatibility. I know you say feel free to enhance this answer, but it's just a minor edit. – Manuel Jul 27 '15 at 12:05
• @Manuel, changed – daleif Jul 27 '15 at 14:54
• The content of the texlive-fontconfig.conf file is here. (Unfortunately it is not distributed with the debian package, apparently.) – Olivier Cailloux Sep 23 '15 at 14:30
• @OlivierCailloux Unfortunately the texlive-fontconfig.conf you've linked references the directories (/usr/local/...) used by tlmgr — it's however easy to understand which modifications are required Thank you for posting the link. – gboffi Nov 17 '17 at 14:47

If you create some symbolic links you can avoid the need to update the configuration file when you install a new edition of TeX Live.

As the user who manages your TeX installation (probably this means root or sudo):

cd /usr/local/texlive
ln -s 2015 current.2015
ln -s current.2015 current


The configuration file 09-texlive-fonts.conf should be created in /etc/fonts/conf.avail with a symbolic link from /etc/fonts/conf.d. So, as root or with sudo, create /etc/fonts/conf.avail/09-texlive-fonts.conf with the following content:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir>/usr/local/texlive/current/texmf-dist/fonts/opentype</dir>
<dir>/usr/local/texlive/current/texmf-dist/fonts/truetype</dir>
<dir>/usr/local/texlive/current/texmf-dist/fonts/type1</dir>
</fontconfig>


If you also want to make available fonts from TEXMFLOCAL:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir>/usr/local/texlive/current/texmf-dist/fonts/opentype</dir>
<dir>/usr/local/texlive/current/texmf-dist/fonts/truetype</dir>
<dir>/usr/local/texlive/current/texmf-dist/fonts/type1</dir>
<dir>/usr/local/texlive/texmf-local/fonts/opentype</dir>
<dir>/usr/local/texlive/texmf-local/fonts/truetype</dir>
<dir>/usr/local/texlive/texmf-local/fonts/type1</dir>
</fontconfig>


Then as root or with sudo:

cd /etc/fonts/conf.d
ln -s ../conf.avail/09-texlive-fonts.conf
fc-cache -s


If you update TeX Live or install a new version, you can simply adjust the symbolic links and run fc-cache -fs. In fact, in many cases, the cache will get updated relatively quickly even if you don't run fc-cache because you will get some font package or other updated by your distro package manager when you update the system.

Do note that for some applications you would also need to run mkfontscale and mkfontdir.

• why do you create a softlink to current.2015 rather than directly link 2015 to current ? Is there any reason or advantage doing it this way ? – SPV Jan 6 '18 at 3:48
• @SPV It just makes it easier to switch and clearer to me what I'm doing. It means I can leave the precise links in place when switching: current.2015, current.2016, bin.2015, bin.2016 etc. and everything relevant stays in the top-level directory, even if that version is not the active one. It also makes it possible to do things like /usr/local/texlive/bin.2015/pdflatex when 2015 is not the active version - and similarly for setting the main tree in the environment. – cfr Jan 6 '18 at 21:05