Subject: Modular TexLive "Insufficient extension fonts" and duplicate fonts

From: Jelle Licht <[email-masked]>
Date: Sat, 11 Apr 2020 18:15:08 +0200

I think I found a bug in our amsfonts texlive package. I will describe
my journey in finding this bug, as I still do not have clear picture
on the why/when/what is going on. I think I also saw several other
people running into this issue the last few months, so either way I am
happy to have found something reproducible that at least demonstrates
that I am sane :).

The eror message is:
" ! Math formula deleted: Insufficient extension fonts."

If you, like me, want to use Emacs' org-mode capabilities and export to
pdf using latex, by default you will generate an intermediate .tex file
that uses the ulem package. Using this package leads to the
aforementioned error message.

(Skip everything after this if you do not care about my descent into madness)

I used a profile containing the following (relevant) texlive packages:
--8<---------------cut here---------------start------------->8---
texlive-base	
texlive-latex-preview	
texlive-latex-base	
texlive-latexconfig	
texlive-fonts-ec	
texlive-latex-oberdiek	
texlive-latex-wrapfig	
texlive-generic-ulem	
texlive-latex-capt-of	
texlive-latex-hyperref
texlive-amsfonts	
texlive-fontinst	
texlive-metafont-base	
texlive-unicode-data	
texlive-pstool	
texlive-cm	
texlive-cm-super	
texlive-latex-amscls	
texlive-fonts-latex	
texlive-latex-amsmath	
--8<---------------cut here---------------end--------------->8---

I ran both `strace pdflatex working 2> working-strace.log' and `strace
pdflatex broken 2> broken-strace.log' See the attached `working.tex'
and `broken.tex' for tiny examples that demonstrate this.

The relevant part of the diff between straces:

* Working:
--8<---------------cut here---------------start------------->8---
access("/home/jlicht/.guix-profile/share/texmf-dist/fonts/tfm/public/amsfonts/cmex7.tfm", R_OK) = 0
stat("/home/jlicht/.guix-profile/share/texmf-dist/fonts/tfm/public/amsfonts/cmex7.tfm", {st_mode=S_IFREG|0444, st_size=940, ...}) = 0
openat(AT_FDCWD, "/home/jlicht/.guix-profile/share/texmf-dist/fonts/tfm/public/amsfonts/cmex7.tfm", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=940, ...}) = 0
read(6, "\0\353\0\2\0\0\0\177\0#\0\6\0\16\0\3\0\0\0\0\0\34\0\r\27#\260\255\0p\0\0"..., 4096) = 940
close(6)                                = 0
openat(AT_FDCWD, "working.pdf", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 6
write(1, " [1", 3)                      = 3
--8<---------------cut here---------------end--------------->8---

* Broken:
--8<---------------cut here---------------start------------->8---
access("/home/jlicht/.guix-profile/share/texmf-dist/fonts/tfm/public/amsfonts/euler/cmex7.tfm", R_OK) = 0
stat("/home/jlicht/.guix-profile/share/texmf-dist/fonts/tfm/public/amsfonts/euler/cmex7.tfm", {st_mode=S_IFREG|0444, st_size=1312, ...}) = 0
openat(AT_FDCWD, "/home/jlicht/.guix-profile/share/texmf-dist/fonts/tfm/public/amsfonts/euler/cmex7.tfm", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0444, st_size=1312, ...}) = 0
read(6, "\1H\0\21\0\0\0\332\0*\0\20\0\20\0\6\0\0\0\0\0\0\0\6d\235jM\0\240\0\0"..., 4096) = 1312
close(6)                                = 0
write(1, "\n", 1)                       = 1
write(1, "! Math formula deleted: Insuffic"..., 54) = 54
--8<---------------cut here---------------end--------------->8---

We see that a different file is used when resolving the same font!
Furthermore, one of these fonts is a totally different size than the
other.

If we run: `guix build --check texlive-amsfonts | grep cmex7', we see:
--8<---------------cut here---------------start------------->8---
Font metrics written on /tmp/guix-build-texlive-amsfonts-49435.drv-0/source/build-fonts/cmex7.tfm.
Output written on /tmp/guix-build-texlive-amsfonts-49435.drv-0/source/build-fonts/cmex7.600gf (128 characters, 30684 bytes).
Transcript written on /tmp/guix-build-texlive-amsfonts-49435.drv-0/source/build-fonts/cmex7.log.
converting afm font cmex7
cmex7 CMEX7
`build-fonts/cmex7.600gf' -> `/gnu/store/hrxlw7s1d8q0z5kipizjr7ib49bw4hjp-texlive-amsfonts-49435/share/texmf-dist/fonts/tfm/public/amsfonts/cmex7.600gf'
`build-fonts/cmex7.tfm' -> `/gnu/store/hrxlw7s1d8q0z5kipizjr7ib49bw4hjp-texlive-amsfonts-49435/share/texmf-dist/fonts/tfm/public/amsfonts/cmex7.tfm'
`build-fonts/euler/cmex7.tfm' -> `/gnu/store/hrxlw7s1d8q0z5kipizjr7ib49bw4hjp-texlive-amsfonts-49435/share/texmf-dist/fonts/tfm/public/amsfonts/euler/cmex7.tfm'
--8<---------------cut here---------------end--------------->8---

AFAIK, and from looking at the full (and correctly working)
texlive-texmf build, the cmex7.tfm in `euler' is not correctly build.
My best guess is that this happens because cmex has both a mf file and a
afm file in `guix build --source texlive-amsfonts'. The one 'built'
using afm2tfm seems to be broken and/or not matching other metadata
generated, as given by this example.

Thanks for reading along, I hope we will find a solution to this, as
non-modular texlive is simply the worst :).

 - Jelle