Skip to content

Commit 0f699f3

Browse files
committed
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
1 parent d5f5ad2 commit 0f699f3

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

news/changelog-1.9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ All changes included in 1.9:
4545
- ([#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.
4646
- ([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.
4747
- ([#13667](https://github.com/quarto-dev/quarto-cli/issues/13667)): Fix LaTeX compilation error with Python error output containing caret characters.
48+
- ([#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.
4849

4950
## Projects
5051

src/command/render/latexmk/parse-error.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ const packageMatchers = [
297297
];
298298

299299
function fontSearchTerm(font: string): string {
300-
return `${font}(-(Bold|Italic|Regular).*)?[.](tfm|afm|mf|otf|ttf)`;
300+
const fontPattern = font.replace(/\s+/g, '\\s*');
301+
return `${fontPattern}(-(Bold|Italic|Regular).*)?[.](tfm|afm|mf|otf|ttf)`;
301302
}
302303

303304
function findMissingPackages(logFileText: string): string[] {

tests/unit/latexmk/parse-error.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import { unitTest } from "../../test.ts";
1010
import { assert } from "testing/asserts";
1111

1212
function fontSearchTerm(font: string): string {
13-
return `${font}(-(Bold|Italic|Regular).*)?[.](tfm|afm|mf|otf|ttf)`;
13+
const fontPattern = font.replace(/\s+/g, '\\s*');
14+
return `${fontPattern}(-(Bold|Italic|Regular).*)?[.](tfm|afm|mf|otf|ttf)`;
1415
}
1516

1617
function assertFound(logText: string, expected: string, file?: string) {
@@ -32,6 +33,8 @@ unitTest("Detect missing files with `findMissingFontsAndPackages`", async () =>
3233
assertFound('!pdfTeX error: /usr/local/bin/pdflatex (file tcrm0700): Font tcrm0700 at 600 not found', fontSearchTerm("tcrm0700"))
3334
assertFound('(fontspec) The font "LibertinusSerif-Regular" cannot be', fontSearchTerm("LibertinusSerif-Regular"));
3435
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");
36+
assertFound('! The font "Noto Emoji" cannot be found.', fontSearchTerm("Noto Emoji"));
37+
assertFound('! Package fontspec Error: The font "DejaVu Sans" cannot be found.', fontSearchTerm("DejaVu Sans"));
3538
assertFound("! LaTeX Error: File `framed.sty' not found.", "framed.sty");
3639
assertFound("! LaTeX Error: File 'framed.sty' not found.", "framed.sty");
3740
assertFound("/usr/local/bin/mktexpk: line 123: mf: command not found", "mf");

0 commit comments

Comments
 (0)