Skip to content

Commit b586e72

Browse files
claude: fix relative font-paths in typst extensions (#13745)
Only resolve font paths that come from extensions (paths containing _extensions or starting with ..) relative to the input directory. Other relative paths like .quarto/typst-font-cache should remain relative to the working directory where typst runs. This fixes the issue where font-paths specified in extension configurations weren't being found when the input document was in a subdirectory, while preserving correct behavior for brand font cache paths. Adds a test case that verifies extension font-paths work correctly when the document is in a subdirectory. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b337042 commit b586e72

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

news/changelog-1.9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ All changes included in 1.9:
4141
- ([#13555](https://github.com/quarto-dev/quarto-cli/issues/13555)): Add support for `icon=false` in callouts when used in `format: typst`.
4242
- ([#13589](https://github.com/quarto-dev/quarto-cli/issues/13589)): Fix callouts with invalid ID prefixes crashing with "attempt to index a nil value". Callouts with unknown reference types now render as non-crossreferenceable callouts with a warning, ignoring the invalid ID.
4343
- ([#13602](https://github.com/quarto-dev/quarto-cli/issues/13602)): Fix support for multiple files set in `bibliography` field in `biblio.typ` template partial.
44+
- ([#13745](https://github.com/quarto-dev/quarto-cli/issues/13745)): Fix relative `font-paths` in custom Typst format extensions not working when the input document is in a subdirectory. Extension font paths are now resolved relative to the input file directory.
4445
- ([#13775](https://github.com/quarto-dev/quarto-cli/issues/13775)): Fix brand fonts not being applied when using `citeproc: true` with Typst format. Format detection now properly handles Pandoc format variants like `typst-citations`.
4546
- ([#13249](https://github.com/quarto-dev/quarto-cli/pull/13249)): Update to Pandoc's Typst template following Pandoc 3.8.3 and Typst 0.14.2 support:
4647
- Code syntax highlighting now uses Skylighting by default.

src/command/render/output-typst.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,22 @@ export function typstPdfOutputRecipe(
6969
// run typst
7070
await validateRequiredTypstVersion();
7171
const pdfOutput = join(inputDir, inputStem + ".pdf");
72-
// Resolve font paths to absolute paths since typst compile may run from
73-
// a different working directory than the input file's directory
72+
// Resolve extension font paths to absolute paths since typst compile runs
73+
// from the project root, not the input file's directory. Extension paths
74+
// (containing _extensions or starting with ..) need resolution relative to
75+
// inputDir, while other paths (like .quarto/font-cache) should remain
76+
// relative to the working directory.
7477
const fontPaths = asArray(format.metadata?.[kFontPaths]).map((p) => {
7578
const fontPath = p as string;
76-
return isAbsolute(fontPath) ? fontPath : join(inputDir, fontPath);
79+
if (isAbsolute(fontPath)) {
80+
return fontPath;
81+
}
82+
// Extension-resolved paths need to be resolved relative to input file
83+
if (fontPath.includes("_extensions") || fontPath.startsWith("..")) {
84+
return join(inputDir, fontPath);
85+
}
86+
// Other relative paths (like .quarto/...) stay relative to working dir
87+
return fontPath;
7788
});
7889
const typstOptions: TypstCompileOptions = {
7990
quiet: options.flags?.quiet,

0 commit comments

Comments
 (0)