Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/changelog-1.9.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ All changes included in 1.9:
- ([#13555](https://github.com/quarto-dev/quarto-cli/issues/13555)): Add support for `icon=false` in callouts when used in `format: typst`.
- ([#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.
- ([#13602](https://github.com/quarto-dev/quarto-cli/issues/13602)): Fix support for multiple files set in `bibliography` field in `biblio.typ` template partial.
- ([#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.
- ([#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`.
- ([#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:
- Code syntax highlighting now uses Skylighting by default.
Expand Down
27 changes: 25 additions & 2 deletions src/command/render/output-typst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
* Copyright (C) 2020-2022 Posit Software, PBC
*/

import { dirname, join, normalize, relative } from "../../deno_ral/path.ts";
import {
dirname,
isAbsolute,
join,
normalize,
relative,
} from "../../deno_ral/path.ts";
import { ensureDirSync, safeRemoveSync } from "../../deno_ral/fs.ts";

import {
Expand Down Expand Up @@ -63,9 +69,26 @@ export function typstPdfOutputRecipe(
// run typst
await validateRequiredTypstVersion();
const pdfOutput = join(inputDir, inputStem + ".pdf");
// Resolve extension font paths to absolute paths since typst compile runs
// from the project root, not the input file's directory. Extension paths
// (containing _extensions or starting with ..) need resolution relative to
// inputDir, while other paths (like .quarto/font-cache) should remain
// relative to the working directory.
const fontPaths = asArray(format.metadata?.[kFontPaths]).map((p) => {
const fontPath = p as string;
if (isAbsolute(fontPath)) {
return fontPath;
}
// Extension-resolved paths need to be resolved relative to input file
if (fontPath.includes("_extensions") || fontPath.startsWith("..")) {
Copy link
Contributor Author

@gordonwoodhull gordonwoodhull Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, this is a messy fix - might be better to understand why we are using file-relative paths here and use project-relative instead.

return join(inputDir, fontPath);
}
// Other relative paths (like .quarto/...) stay relative to working dir
return fontPath;
});
const typstOptions: TypstCompileOptions = {
quiet: options.flags?.quiet,
fontPaths: asArray(format.metadata?.[kFontPaths]) as string[],
fontPaths,
};
if (project?.dir) {
typstOptions.rootDir = project.dir;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: test-fonts
author: Quarto
version: 1.0.0
quarto-required: ">=1.4.0"
contributes:
formats:
typst:
font-paths:
- fonts
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/docs/smoke-all/typst/extension-font-paths/_quarto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
project:
type: default
16 changes: 16 additions & 0 deletions tests/docs/smoke-all/typst/extension-font-paths/subdir/doc.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: Extension Font Paths Test
format: test-fonts-typst
_quarto:
tests:
typst:
printsMessage:
level: INFO
regex: 'warning: unknown font family'
negate: true
---

```{=typst}
#set text(font: "Amaranth")
Testing font from extension with relative font-paths.
```
Loading