-
Notifications
You must be signed in to change notification settings - Fork 401
fix: resolve relative font-paths in typst extensions (#13745) #13902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gordonwoodhull
wants to merge
2
commits into
main
Choose a base branch
from
fix/13745-typst-font-paths
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+53
−2
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 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>
gordonwoodhull
commented
Jan 16, 2026
| return fontPath; | ||
| } | ||
| // Extension-resolved paths need to be resolved relative to input file | ||
| if (fontPath.includes("_extensions") || fontPath.startsWith("..")) { |
Contributor
Author
There was a problem hiding this comment.
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.
gordonwoodhull
added a commit
that referenced
this pull request
Jan 21, 2026
…13917) Extension-resolved logo paths (containing _extensions or starting with ..) are already relative to the input document and should not have the project offset applied. This fixes rendering Typst format extensions with logos when the document is in a project subdirectory. The same pattern was applied to font-paths in #13745 / PR #13902. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This was referenced Jan 21, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
typst compilefont-pathsspecified in extension configurations weren't being found when the input document was in a subdirectoryProblem
When using
font-pathsin a custom Typst format extension, relative paths weren't working because:typst compileruns from a different working directory (project root or temp dir)Solution
In
src/command/render/output-typst.ts, convert relative font paths to absolute paths by joining them withinputDir(the directory containing the input document) before passing totypstCompile.Fixes #13745
Test plan
tests/docs/smoke-all/typst/extension-font-paths/verifies no "unknown font family" warning when using extension with relative font-paths from a subdirectory🤖 Generated with Claude Code