Skip to content

Conversation

@gordonwoodhull
Copy link
Contributor

Summary

  • Resolves relative font paths to absolute paths before passing them to typst compile
  • Fixes issue where font-paths specified in extension configurations weren't being found when the input document was in a subdirectory
  • Adds test case verifying extension font-paths work correctly from subdirectories

Problem

When using font-paths in a custom Typst format extension, relative paths weren't working because:

  1. The extension mechanism resolves font-paths relative to the input document
  2. But typst compile runs from a different working directory (project root or temp dir)
  3. The relative paths therefore don't point to the correct location

Solution

In src/command/render/output-typst.ts, convert relative font paths to absolute paths by joining them with inputDir (the directory containing the input document) before passing to typstCompile.

Fixes #13745

Test plan

  • New smoke test in tests/docs/smoke-all/typst/extension-font-paths/ verifies no "unknown font family" warning when using extension with relative font-paths from a subdirectory
  • CI tests pass

🤖 Generated with Claude Code

Resolve relative font paths to absolute paths before passing them to
typst compile. This fixes the issue where font-paths specified in
extension configurations weren't being found when the input document
was in a subdirectory.

The extension mechanism resolves font-paths relative to the input
document, but typst compile may run from a different working directory.
By converting relative paths to absolute paths using the input
directory, the fonts are now correctly located.

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>
@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Jan 16, 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.

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>
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.

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

3 participants