# Fontspec finding no fonts for XeLaTeX

Consider this MWE:

\documentclass{minimal}

\usepackage{fontspec}
\setmainfont{Latin Modern Roman}
\setsansfont{Latin Modern Sans}
\setmonofont{Latin Modern Mono}

\begin{document}
X marks the spot.
\end{document}

Using the standard ISO of TeXLive 2014 on Ubuntu 14.04.1, LuaLaTex compiles this; XeLaTeX, on the other hand, gives this error:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "Latin Modern Roman" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................

l.4   \setmainfont{Latin Modern Roman}

What’s going on, and how do I fix this?

\usepackage{fontspec}

is sufficient. It will set the fonts to Latin Modern by default. That said, your code compiles fine for me.

I am not that familiar with XeLaTeX. However, I know it uses OS fonts and I know it handles things differently from LuaLaTeX. So you may need to tell your system about the TeX fonts. For example, I have the following configuration file /etc/fonts/conf.avail/09-texlive-fonts.conf:

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

This is then sym linked from /etc/fonts/conf.d/. You then would need to update the fontconfig cache etc. However, the best way to handle this is to see if your distro has a package which does something similar when its own packages are installed. If it does, just follow the lead of that package, adapting it for an upstream install.

Useful commands: mkfontscale, mkfontdir fc-cache. But check your distro - it may prefer wrappers for some of these commands.

Note that my use of current may not work for you. You likely need 2014 instead.

• Fortunately, this works in this particular case, but I would like to keep waiting for further answers, since my original code used to work. – Adam Khan Dec 1 '14 at 2:09
• @AdamKhan And it should work. It works for me. Are you sure that the Latin Modern fonts are installed system-wide? (Not just for TeX.) Can you use other system fonts? – cfr Dec 1 '14 at 2:14
• @AdamKhan Just realised: don't mark this answer as accepted! You are hoping for a more satisfactory one. If you don't get one in a couple of days, it would be reasonable to accept this one. But don't do it now. (You can unaccept it, I think.) – cfr Dec 1 '14 at 2:16
• System fonts work, even those with spaces. Only TeX fonts fail. I used sudo ./install-tl to install TeXLive. – Adam Khan Dec 1 '14 at 2:21
• @AdamKhan I do not use XeLaTeX much but, as I understand it, it uses system fonts. So I think you need to have the TeX fonts included with your system fonts. (LuaLaTeX does things a bit differently.) For example, I created... – cfr Dec 1 '14 at 2:27