1

I have TexLive 2021. OS and TexLive specs: OS Ubuntu Linux 20.04.4 LTS, TeXLive installed from the Internet, it is located in /usr/local/texlive/2021. Compilation log: https://pastebin.com/50pVKYWB

Previously the Concrete family of fonts was working:

\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\usepackage[english]{babel}
\usepackage{ccfonts}
\usepackage{fontspec}
\setmainfont{CMU Concrete}
\setsansfont{CMU Sans Serif}
\setmonofont{CMU Typewriter Text}
\begin{document}
\noindent
The Concrete Roman fonts were designed by Don Knuth for a book called
``Concrete Mathematics'', which he wrote with Graham and Patashnik
(the Patashnik, of BibTeX fame). 
\end{document}

Now when I try to compile the document it doesn't:

Package fontspec Error: The font "CMU Concrete" cannot be found.

How to install it and make it usable?

user4035
  • 5,035
  • 6
  • 40
  • 57
  • Compiles fine for me on Tex Live 2022. – Ingmar Jun 21 '22 at 08:23
  • When you say that you have TeXLive 2021, exactly what have you installed? Which operating system? Is this linux? and is TeXLive then coming from the linux dist? – daleif Jun 21 '22 at 08:35
  • @daleif Updated the question with specs. – user4035 Jun 21 '22 at 08:43
  • 1
    I ask again what you you mean by TeXLive installed from the Internet? Did you manually install TeXLive 2021? Can you provide the log from your compilation? That can reveal if you have two different latex installations. – daleif Jun 21 '22 at 08:48
  • 1
    Also, have you tried using lualatex instead of xelatex? For me xelatex often has issues finding TeXLive fonts, whereas lualatex just works. – daleif Jun 21 '22 at 08:50
  • @daleif "have you tried using lualatex instead of xelatex?" - I tried, it works. So, the font is there. xelatex is just unable to find it. – user4035 Jun 21 '22 at 08:58
  • @daleif "Can you provide the log from your compilation? " - just checked apt list --installed - there is no TeXLive there. I found the dir from which I manually did the installation. Where is the log there? – user4035 Jun 21 '22 at 09:00
  • LaTeX produces a log every time you compile. That is where error comes from. – daleif Jun 21 '22 at 09:01
  • @daleif The log: https://pastebin.com/50pVKYWB – user4035 Jun 21 '22 at 09:02
  • If LuaLaTeX finds the font, then use that instead of XeLaTeX. You'll need to add the TeXLive fonts you what Ubuntu thinks are the system fonts for XeLaTeX to be able to find it. It is just a lot easier to use LuaLaTeX instead. – daleif Jun 21 '22 at 09:02
  • Is there any reason for using XeLaTeX over LuaLaTeX? Also note that the latest TL is now 2022. – daleif Jun 21 '22 at 09:04
  • @daleif "Is there any reason for using XeLaTeX over LuaLaTeX?" - no, I can use LuaLaTeX. – user4035 Jun 21 '22 at 09:05
  • @daleif How to add fonts for xelatex? – user4035 Jun 21 '22 at 09:05
  • No idea, I tend to just use lualatex, much easier. Also I think there was a lot of nice speed gains in TL2022, so using that instead, is recommended. – daleif Jun 21 '22 at 09:07
  • @Ingmar What OS are you using? Maybe this is specific to Ubuntu? – user4035 Jun 21 '22 at 09:07
  • @daleif Ok, I'll install TL2022 when I have time. – user4035 Jun 21 '22 at 09:07
  • I doubt it. I am using Win 10 here, will try on my Linux Laptop, too. – Ingmar Jun 21 '22 at 09:27

3 Answers3

1

The problem is likely that your TeX Live font directories are not being searched and indexed by fc-cache. From the path you gave, you did a custom installation, and the TeX Live installer does not set this up by default.

You can test this by first searching for the file itself with the command, kpsewhich cmunorm.otf, which should print the pathname. Then, fc-match "CMU Concrete" should duplicate the search that XeLaTeX does for this file, and luaotfload-tool --find "CMU Concrete" should duplicate the search that LuaLaTeX does.

If the kpsewhich command works, fc-match fails and luaotfload-tool succeeds, your problem is that the font cache is not configured to search your TeX Live directory for font files. The configuration file to do this comes with TeX Live, but is not installed system-wide by default, and you want to put a symbolic link to it in the correct configuration directory. On Ubuntu, one command for that is:

Old Version

sudo ln -s /usr/local/texlive/2021/texmf-var/fonts/conf/texlive-fontconfig.conf \
/etc/fonts/conf.d/09-texlive2021.conf

Correction

In TeX Live 2021, the sample .conf file does not work properly, and should instead be copied with cp, then edited to remove the line

<dir>/usr/local/texlive/2021/texmf-dist/fonts/type1</dir>

You might then want to run fc-cache -f -v to refresh your font cache. If luaotfload-tool fails, you might want to force it to prefer files in your TeX tree with luaotfload-tool -f -u -p -v.

You can find more tips for the configuration I use, including how to install optional fonts and enable fonts in your texmf-local tree, here.

If for some reason you cannot change the system configuration, workarounds are to put a symbolic link to your TeX Live font directories in a user font directory (~/.fonts/ should work) or to load the font by filename, e.g.

\setmainfont{cmuno}[
   Ligatures={Common,TeX},
   UprightFont={*rm},
   BoldFont={*bx},
   ItalicFont={*ti},
   BoldItalicFont={*bi},
   Extension=.otf ]

The list of filenames for all the Computer Modern Unicode fonts is here.

Davislor
  • 44,045
  • Oh, no. Sorry. It found the font at first, then gave an error: xdvipdfmx:fatal: Invalid font: -1 (0) – user4035 Jun 21 '22 at 09:19
  • @user4035 What does which xelatex return? – Davislor Jun 21 '22 at 09:21
  • Compilation log: https://pastebin.com/CwXGKuS5 – user4035 Jun 21 '22 at 09:23
  • cmunorm.otf: "CMU Concrete" "Roman" prints: cmunorm.otf: "CMU Concrete" "Roman". So, it is visible. – user4035 Jun 21 '22 at 09:24
  • @user4035 That log file is a bit more than what I asked for, but it says it’s finding CMU Concrete, and not the bold font. (However, there isn’t actually a bold version of CMU Concrete.) – Davislor Jun 21 '22 at 09:27
  • Is there a reason you’re compiling to DVI, rather than directly to PDF with xelatex or lualatex? – Davislor Jun 21 '22 at 09:29
  • "Is there a reason you’re compiling to DVI, rather than directly to PDF" - no, I don't need DVI. I just ran xelatex ./test.tex and started to produce DVI. – user4035 Jun 21 '22 at 09:31
  • "it says it’s finding CMU Concrete, and not the bold font" - how to compile to pdf without DVI? It tries to search all the fonts in the family? – user4035 Jun 21 '22 at 09:32
  • 1
    @user4035 Just running xelatex should work. I’m at the limit of how much I can help you in the comments. Now that it can find the font file, it appears that there’s some other error in your document. You might try posting a MWE as a new question. – Davislor Jun 21 '22 at 09:35
  • I found the solution. Updated your answer for future generations. – user4035 Jun 21 '22 at 09:59
  • @user4035 I’d appreciate it if you posted that as a self-answer. – Davislor Jun 21 '22 at 10:06
  • "I’d appreciate it if you posted that as a self-answer" - done. – user4035 Jun 21 '22 at 10:12
1

supplement for @Davislor answer: solution of the second problem.

Solution for xdvipdfmx:fatal: Invalid font: -1 (0) error

$ sudo bash
# cd /usr/local/texlive/2021/texmf-var/fonts/conf
# cp ./texlive-fontconfig.conf ./texlive-fontconfig.conf.bak
# vim ./texlive-fontconfig.conf

Remove the line:

<dir>/usr/local/texlive/2021/texmf-dist/fonts/type1</dir>

Then update the font cache:

# fc-cache -fsv

Links for related problem:

user4035
  • 5,035
  • 6
  • 40
  • 57
0

In Ubuntu, if everything else fails, install package texlive-fonts-extra.