0

I would like to use XITS/XITS Math within my LaTeX project (which uses XeTeX). Following the answers to this question, I created a file /etc/fonts/conf.avail/76-texlive-fonts.conf with the following content:

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

I had checked the above paths before to make sure that they are correct:

$ ls -l /usr/share/texlive/texmf-dist/fonts/opentype/public/xits
-rw-r--r-- 1 root root 111280 Nov 25  2016 xits-bolditalic.otf
-rw-r--r-- 1 root root 151692 Nov 25  2016 xits-bold.otf
-rw-r--r-- 1 root root 115536 Nov 25  2016 xits-italic.otf
-rw-r--r-- 1 root root 248956 Nov 25  2016 xits-mathbold.otf
-rw-r--r-- 1 root root 530128 Nov 25  2016 xits-math.otf
-rw-r--r-- 1 root root 249372 Nov 25  2016 xits-regular.otf

Afterwards, I added a symlink to /etc/fonts/conf.d/:

$ ls -l /etc/fonts/conf.d/76-texlive-fonts.conf 
lrwxrwxrwx 1 root root 35 Jan 10 13:15 /etc/fonts/conf.d/76-texlive-fonts.conf -> ../conf.avail/76-texlive-fonts.conf

…and ran $ fc-cache -fv. Its output, among others was:

/usr/share/texlive/texmf-dist/fonts/opentype/public/xits: caching, new cache contents: 6 fonts, 0 dirs

Still, when I run fc-list | grep -i xits now, there is no output and compiling the below MWE gives the following error, as expected:

…
main.tex:11: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! [\setmainfont{XITS}]
main.tex:11: Font TU/XITS(0)/m/n/12=XITS at 12.0pt not loadable: Metric (TFM) file or installed font not found. [\setmainfont{XITS}]
…
main.tex:12: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! [\setmathfont{XITS Math}]
main.tex:12: Font TU/XITSMath(0)/m/n/12="XITS Math/OT" at 12.0pt not loadable: Metric (TFM) file or installed font not found.
…

Here is the MWE:

\documentclass[12pt,a4paper]{article}

\usepackage{fontspec}
\usepackage{unicode-math}


\setmainfont{XITS}
\setmathfont{XITS Math}

\begin{document}
  Hello! Some math: $y = f(x)$

\end{document}

I would very much appreciate any pointers to how I could fix or at least debug this problem!


[UPDATE]: Turns out none of the fonts in /usr/share/texlive/texmf-dist/fonts/ show up in fc-list: The output of $ fc-list | grep /usr/share/texlive/texmf-dist/fonts is completely empty. Nevertheless, dozens of fonts get recognized when running sudo fc-cache -fv | grep /usr/share/texlive/texmf-dist/fonts. What is going on here?

3 Answers 3

2

An update for 2024: While you fixed this, the recommended way to load fonts in fontspec and unicode-math is now by filename. (See also §2.2 of the fontspec manual.) You’ve given an example of how XeTeX can’t look up the display names of fonts in the TeX tree out of the box on some systems, and there are several other situations in which I’ve seen a font’s display name fail, or XeTeX and LuaTeX behave differently.

\defaultfontfeatures[XITS]{
    Ligatures=Default,
    UprightFont=*-Regular,
    BoldFont=*-Bold,
    ItalicFont=*-Italic,
    BoldItalicFont=*-BoldItalic,
    Extension=.otf}

\setmainfont{XITS}
\setmathfont{XITSMath-Regular.otf}
\setmathfont[version=bold]{XITSMath-Bold.otf}

This tells fontspec that the files are named XITS-Regular.otf, XITS-Bold.otf and so on. It will search for system fonts, as well as in the TeX tree and the current folder. You can also specify a Path=, which should normally be something like ./fonts/ to archive the files your document uses in a subdirectory, rather than count on the correct version to always be available under the correct name on every system where someone will try to compile the document, forever.

Remember that filenames are case-sensitive on Linux. Here, I’ve used the filenames from the CTAN distribution, but the OP says that, on their box, the filenames should be in lowercase.

If you are only loading XITS through \setmainfont, you could instead pass the options there, but \defaultfontfeatures[XITS] will work even if you load the font multiple times. You could also put the command into a file named XITS.fontspec.

Finally, the commands to load a font from a .ttc collection by filename, if the display name does not work for you, are in §3.4 of the fontspec manual.

8
  • If the recommended way for fontspec is filename, why \setmainfont{XITS} which clearly doesn't use the filename directly?
    – cfr
    Commented Jun 19 at 5:27
  • Do you have a source for fontspec's preference? I just read several pages of the manual concerned with loading fonts and don't find any such recommendation. Also, as you commented at tex.stackexchange.com/questions/523711/…, filenames are case-sensitive on Linux.
    – cfr
    Commented Jun 19 at 5:44
  • @cfr Will Robertson said so in his TuG 2018 speech.
    – Davislor
    Commented Jun 19 at 7:09
  • @cfr The \defaultfontfeatures[XITS] command tells it the filenames. The keys BoldFont=*-Bold and Extension=.otf mean that the bold upright font is XITS-Bold.otf. You can also specify a Path=. Without these, XeLaTeX or luaotfload have to guess what the other font faces are, and sometimes they do different things.
    – Davislor
    Commented Jun 19 at 7:12
  • @cfr As for capitalization, these are how the files are named on CTAN. XITS is in caps. (I assume Khaled Hosny made that choice because STIX was.)
    – Davislor
    Commented Jun 19 at 7:14
1

I was being a moron: I ran fc-cache as root and fc-list as a regular user without realizing that the cache would then be built for the root user and not the regular user. Running both commands as regular user fixed the issue.

2
  • This sounds weird. Usually, they are systemwide.
    – cfr
    Commented Jun 19 at 5:24
  • On my system, they are in /var/cache/fontconfig/<string>-le64.cache-<number>. You shouldn't have to run it as a regular user unless root and sudo are locked down and don't have access to all the font directories for security reasons.
    – cfr
    Commented Jun 19 at 6:41
0

for xetex use the file names instead of the symbolic names:

\setmainfont{xits-regular.otf}
\setmathfont{xits-math.otf}
\setmathfont[version=bold]{xits-mathbold.otf}
2
  • This does not correctly load the other font faces. Also, filenames are case-sensitive on Linux.
    – Davislor
    Commented Jun 18 at 23:55
  • There is nothing wrong with the filenames in this answer, though it is true that the main font declaration will not ensure other shapes/weights etc. are loaded.
    – cfr
    Commented Jun 19 at 5:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .