Skip to content

fix(pdf): auto-install fonts missing from font fallbacks#14559

Merged
cderv merged 1 commit into
mainfrom
fix/issue-14558
May 29, 2026
Merged

fix(pdf): auto-install fonts missing from font fallbacks#14559
cderv merged 1 commit into
mainfrom
fix/issue-14558

Conversation

@cderv
Copy link
Copy Markdown
Member

@cderv cderv commented May 29, 2026

When a font listed in monofontfallback (or any mainfont/sansfont/monofont fallback) is not installed, the PDF render fails and Quarto makes no attempt to auto-install the missing font.

Root Cause

luaotfload reports the missing fallback font as:

luaotfload | db : Reload initiated (formats: otf,ttf,ttc); reason: Font "DejaVu Sans Mono;-fallback" not found.

The packageMatchers in src/command/render/latexmk/parse-error.ts had no pattern for this format. The primary monofont case only works because fontspec also raises ! Package fontspec Error: The font "X" cannot be found, which is matched. The fallback path registers fonts via luaotfload.add_fallback(); when that fails, fontspec stays silent, so the unrecognized luaotfload message is the only signal.

luaotfload also appends ;-fallback internally to each fallback-chain entry. Left in place, the extracted name corrupts the tlmgr search-term regex.

Fix

Add a matcher for the luaotfload format and strip the ;-fallback suffix before building the search term. DejaVu Sans Mono then resolves to the dejavu CTAN package and auto-installs.

Test Plan

  • Unit test in tests/unit/latexmk/parse-error.test.ts extracts the font name (suffix stripped) from the luaotfload log line
  • Existing parse-error font cases still pass

Manual verification

Rendered a document with pdf-engine: lualatex, monofont: Latin Modern Mono, monofontfallback: [DejaVu Sans Mono] (uninstalled) and a glyph absent from the primary font, using a dev build with this change. The new matcher now fires where nothing did before:

finding package for DejaVu\s*Sans\s*Mono(-(Bold|Italic|Regular).*)?[.](tfm|afm|mf|otf|ttf)
> 1 package to install
> installing dejavu (1 of 1)

tlmgr then installs the dejavu package — the detection and auto-install path works as intended.

Note: completing the PDF still requires a fix outside this change. After the font is installed, luaotfload's fallback resolver looks up the literal suffixed name DejaVu Sans Mono;-fallback, fails, and aborts in luaotfload-fallback.lua even with the font present and its name database rebuilt. This is reproducible with bare lualatex and no Quarto involved, so it is tracked separately and does not affect the scope of this fix (recognizing the error format so auto-install is attempted).

Closes #14558

When a font listed in monofontfallback (or any *fontfallback) is absent,
luaotfload reports it via 'luaotfload | ... reason: Font "X;-fallback"
not found' and fontspec never raises its own catchable error, so Quarto's
missing-package detector saw nothing and the PDF render failed with no
auto-install attempt. The primary monofont case worked only because
fontspec also fires there.

Add a packageMatcher for the luaotfload format and strip the ;-fallback
suffix luaotfload appends internally before building the tlmgr search term,
so 'DejaVu Sans Mono' resolves to the dejavu CTAN package.

Closes #14558
@posit-snyk-bot
Copy link
Copy Markdown
Collaborator

posit-snyk-bot commented May 29, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cderv cderv merged commit baf1b02 into main May 29, 2026
92 of 93 checks passed
@cderv cderv deleted the fix/issue-14558 branch May 29, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

monofontfallback fonts not auto-installed — luaotfload error format not recognized

2 participants