fix(pdf): auto-install fonts missing from font fallbacks#14559
Merged
Conversation
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
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a font listed in
monofontfallback(or anymainfont/sansfont/monofontfallback) 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:
The
packageMatchersinsrc/command/render/latexmk/parse-error.tshad no pattern for this format. The primarymonofontcase only works because fontspec also raises! Package fontspec Error: The font "X" cannot be found, which is matched. The fallback path registers fonts vialuaotfload.add_fallback(); when that fails, fontspec stays silent, so the unrecognized luaotfload message is the only signal.luaotfload also appends
;-fallbackinternally to each fallback-chain entry. Left in place, the extracted name corrupts thetlmgrsearch-term regex.Fix
Add a matcher for the luaotfload format and strip the
;-fallbacksuffix before building the search term.DejaVu Sans Monothen resolves to thedejavuCTAN package and auto-installs.Test Plan
tests/unit/latexmk/parse-error.test.tsextracts the font name (suffix stripped) from the luaotfload log lineManual 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:tlmgrthen installs thedejavupackage — 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 inluaotfload-fallback.luaeven with the font present and its name database rebuilt. This is reproducible with barelualatexand 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