Skip to content

fix: resolve relative font-paths for typst compilation#14068

Merged
gordonwoodhull merged 1 commit intomainfrom
bugfix/13745
Feb 19, 2026
Merged

fix: resolve relative font-paths for typst compilation#14068
gordonwoodhull merged 1 commit intomainfrom
bugfix/13745

Conversation

@gordonwoodhull
Copy link
Contributor

Fixes #13745
Replaces #13902

Summary

  • Resolves relative font-paths to absolute paths against the document directory before passing them to the Typst CLI
  • Fixes the bug where extensions providing font-paths in their _extension.yml fail with "unknown font family" when the document is in a project subdirectory

The root cause: relative font paths (from extensions, document front matter, or project config) were passed unchanged as --font-path arguments to the Typst CLI. Typst resolves these relative to its process CWD, which has no defined relationship to the document directory. This caused failures whenever documents weren't at the project root.

The fix is a two-line change in output-typst.ts that resolves relative paths against inputDir (the document directory) before passing them to typstCompile. Absolute paths (from brand.yaml font resolution or already-resolved /-prefixed project paths) pass through unchanged.

Test plan

  • New smoke test: extension contributing font-paths with document in subdirectory (was failing, now passes)
  • New smoke test: document font-paths in front matter with document in subdirectory (was failing, now passes)
  • New smoke test: brand.yaml file fonts with document in subdirectory (was already passing, confirms no regression)
  • Existing test: relative-font-path project-absolute /artifacts/fonts (confirms no regression)
  • Typechecks clean

🤖 Generated with Claude Code

@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Feb 19, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Fixes #13745

Relative font-paths (from extensions, document metadata, or project
config) were passed unchanged to the typst CLI --font-path argument.
Typst resolves these relative to its CWD, not the document directory,
causing "unknown font family" errors when documents are in project
subdirectories.

Two changes:
- output-typst.ts: resolve relative font-paths against the document
  directory before passing them to typstCompile
- pandoc.ts: ensure brand font directories are absolute so they work
  regardless of CWD

Adds three smoke tests covering extension font-paths, document
font-paths from a subdirectory, and brand font-paths from a
subdirectory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gordonwoodhull gordonwoodhull added this to the v1.9 milestone Feb 19, 2026
@gordonwoodhull gordonwoodhull merged commit baf8fec into main Feb 19, 2026
51 checks passed
@gordonwoodhull gordonwoodhull deleted the bugfix/13745 branch February 19, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

In custom typst format extension, relative or project relative font-paths not working

2 participants

Comments