From 0f699f30ae0313fab696f93145f0c54e9e4d8a21 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Wed, 26 Nov 2025 15:24:26 +0100 Subject: [PATCH 1/2] Fix font package detection for fonts with spaces in names Fonts with spaces (e.g., "Noto Emoji", "DejaVu Sans") were failing auto-installation because fontSearchTerm() generated search patterns that didn't match font files. Font files use concatenated names without spaces (NotoEmoji-Regular.ttf, DejaVuSans-Bold.ttf). Replace spaces with \s* regex pattern to match files with or without spaces. Closes #13726 --- news/changelog-1.9.md | 1 + src/command/render/latexmk/parse-error.ts | 3 ++- tests/unit/latexmk/parse-error.test.ts | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/news/changelog-1.9.md b/news/changelog-1.9.md index 7a59fe013b..c7d56c4b72 100644 --- a/news/changelog-1.9.md +++ b/news/changelog-1.9.md @@ -45,6 +45,7 @@ All changes included in 1.9: - ([#13661](https://github.com/quarto-dev/quarto-cli/issues/13661)): Fix LaTeX compilation errors when using `mermaid-format: svg` with PDF/LaTeX output. SVG diagrams are now written directly without HTML script tags. Note: `mermaid-format: png` is recommended for best compatibility. SVG format requires `rsvg-convert` (or Inkscape with `use-rsvg-convert: false`) in PATH for conversion to PDF, and may experience text clipping in diagrams with multi-line labels. - ([rstudio/tinytex-releases#49](https://github.com/rstudio/tinytex-releases/issues/49)): Fix detection of LuaTeX-ja missing file errors by matching both "File" and "file" in error messages. - ([#13667](https://github.com/quarto-dev/quarto-cli/issues/13667)): Fix LaTeX compilation error with Python error output containing caret characters. +- ([#13732](https://github.com/quarto-dev/quarto-cli/issues/13732)): Fix automatic font package installation for fonts with spaces in their names (e.g., "Noto Emoji", "DejaVu Sans"). Font file search patterns now match both with and without spaces. ## Projects diff --git a/src/command/render/latexmk/parse-error.ts b/src/command/render/latexmk/parse-error.ts index 02a5b1b87d..22ff6d1857 100644 --- a/src/command/render/latexmk/parse-error.ts +++ b/src/command/render/latexmk/parse-error.ts @@ -297,7 +297,8 @@ const packageMatchers = [ ]; function fontSearchTerm(font: string): string { - return `${font}(-(Bold|Italic|Regular).*)?[.](tfm|afm|mf|otf|ttf)`; + const fontPattern = font.replace(/\s+/g, '\\s*'); + return `${fontPattern}(-(Bold|Italic|Regular).*)?[.](tfm|afm|mf|otf|ttf)`; } function findMissingPackages(logFileText: string): string[] { diff --git a/tests/unit/latexmk/parse-error.test.ts b/tests/unit/latexmk/parse-error.test.ts index 7ad40b854b..4771a6d7b4 100644 --- a/tests/unit/latexmk/parse-error.test.ts +++ b/tests/unit/latexmk/parse-error.test.ts @@ -10,7 +10,8 @@ import { unitTest } from "../../test.ts"; import { assert } from "testing/asserts"; function fontSearchTerm(font: string): string { - return `${font}(-(Bold|Italic|Regular).*)?[.](tfm|afm|mf|otf|ttf)`; + const fontPattern = font.replace(/\s+/g, '\\s*'); + return `${fontPattern}(-(Bold|Italic|Regular).*)?[.](tfm|afm|mf|otf|ttf)`; } function assertFound(logText: string, expected: string, file?: string) { @@ -32,6 +33,8 @@ unitTest("Detect missing files with `findMissingFontsAndPackages`", async () => assertFound('!pdfTeX error: /usr/local/bin/pdflatex (file tcrm0700): Font tcrm0700 at 600 not found', fontSearchTerm("tcrm0700")) assertFound('(fontspec) The font "LibertinusSerif-Regular" cannot be', fontSearchTerm("LibertinusSerif-Regular")); assertFound('! Font \\JY3/mc/m/n/10=file:HaranoAjiMincho-Regular.otf:-kern;jfm=ujis at 9.24713pt not loadable: metric data not found or bad.', "HaranoAjiMincho-Regular.otf"); + assertFound('! The font "Noto Emoji" cannot be found.', fontSearchTerm("Noto Emoji")); + assertFound('! Package fontspec Error: The font "DejaVu Sans" cannot be found.', fontSearchTerm("DejaVu Sans")); assertFound("! LaTeX Error: File `framed.sty' not found.", "framed.sty"); assertFound("! LaTeX Error: File 'framed.sty' not found.", "framed.sty"); assertFound("/usr/local/bin/mktexpk: line 123: mf: command not found", "mf"); From 8de8b3119bff2da9bcc49b8ef8b4f27c157c51b4 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Wed, 26 Nov 2025 16:41:12 +0100 Subject: [PATCH 2/2] move to regression fix in changelog --- news/changelog-1.9.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/changelog-1.9.md b/news/changelog-1.9.md index c7d56c4b72..f95efe937f 100644 --- a/news/changelog-1.9.md +++ b/news/changelog-1.9.md @@ -10,6 +10,7 @@ All changes included in 1.9: - ([#13625](https://github.com/quarto-dev/quarto-cli/issues/13625)): Fix Windows file locking error (os error 32) when rendering with `--output-dir` flag. Context cleanup now happens before removing the temporary `.quarto` directory, ensuring file handles are properly closed. - ([#13633](https://github.com/quarto-dev/quarto-cli/issues/13633)): Fix detection and auto-installation of babel language packages from newer error format that doesn't explicitly mention `.ldf` filename. - ([#13694](https://github.com/quarto-dev/quarto-cli/issues/13694)): Fix `notebook-view.url` being ignored - external notebook links now properly use specified URLs instead of local preview files. +- ([#13732](https://github.com/quarto-dev/quarto-cli/issues/13732)): Fix automatic font package installation for fonts with spaces in their names (e.g., "Noto Emoji", "DejaVu Sans"). Font file search patterns now match both with and without spaces. ## Dependencies @@ -45,7 +46,6 @@ All changes included in 1.9: - ([#13661](https://github.com/quarto-dev/quarto-cli/issues/13661)): Fix LaTeX compilation errors when using `mermaid-format: svg` with PDF/LaTeX output. SVG diagrams are now written directly without HTML script tags. Note: `mermaid-format: png` is recommended for best compatibility. SVG format requires `rsvg-convert` (or Inkscape with `use-rsvg-convert: false`) in PATH for conversion to PDF, and may experience text clipping in diagrams with multi-line labels. - ([rstudio/tinytex-releases#49](https://github.com/rstudio/tinytex-releases/issues/49)): Fix detection of LuaTeX-ja missing file errors by matching both "File" and "file" in error messages. - ([#13667](https://github.com/quarto-dev/quarto-cli/issues/13667)): Fix LaTeX compilation error with Python error output containing caret characters. -- ([#13732](https://github.com/quarto-dev/quarto-cli/issues/13732)): Fix automatic font package installation for fonts with spaces in their names (e.g., "Noto Emoji", "DejaVu Sans"). Font file search patterns now match both with and without spaces. ## Projects