Skip to content

Commit f1e71be

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 Fix font package detection for fonts with spaces in names Resolves an issue where fonts packages containing spaces in their names (e.g., "Noto Sans") were not properly detected in Quarto projects. Updated font path handling to correctly quote and process font names with whitespace characters.
1 parent e15a854 commit f1e71be

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎news/changelog-1.8.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## In this release
44

55
- ([#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.
6+
- ([#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.
67

78
## In previous releases
89

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

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

287287
function fontSearchTerm(font: string): string {
288-
return `${font}(-(Bold|Italic|Regular).*)?[.](tfm|afm|mf|otf|ttf)`;
288+
const fontPattern = font.replace(/\s+/g, '\\s*');
289+
return `${fontPattern}(-(Bold|Italic|Regular).*)?[.](tfm|afm|mf|otf|ttf)`;
289290
}
290291

291292
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("/usr/local/bin/mktexpk: line 123: mf: command not found", "mf");
3740
assertFound("or the language definition file ngerman.ldf was not found", "ngerman.ldf");

0 commit comments

Comments
 (0)