Thanks to visit codestin.com
Credit goes to github.com

Skip to content

font-path for typst format in _quarto.yml beginning with / is not resolved relative to project root #12695

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
htbunn opened this issue May 6, 2025 · 4 comments
Assignees
Labels
bug Something isn't working typst
Milestone

Comments

@htbunn
Copy link

htbunn commented May 6, 2025

Bug description

I encountered this issue while trying to put together a custom typst format. I noticed that the font-path I provided in _extension.yml was not being resolved as expected. I searched online and found several posts which seem to be related (e.g., issue #11839 and this discussion) with 2 key takeaways: 1) create a project (via _quarto.yml), and 2) a path prepended with / should resolve relative to the location of the _quarto.yml file.

I've created a minimal working example directory (see below) according to both suggestions and the resulting pdf is still rendered with the default font. However, if I remove the / and call quarto render from within the report1 directory, the font is applied correctly. (cc: @MichaelHatherly )

Steps to reproduce

I've created a repo for the example directory to (hopefully) make it easier to reproduce the issue.

The example directory has the following structure:

relpath-test
├── README.md
├── _quarto.yml
├── artifacts
│   ├── .fonts
│       └── Amaranth-Regular.ttf
└── report1
    └── report.qmd

The _quarto.yml:

format:
  typst:
    font-paths: /artifacts/.fonts
    section-numbering: 1.1.a

The report.qmd test document:

---
title: Test Report
---

```{=typst}
#set text(font: "Amaranth")
Testing my text.
```

From a terminal on my local machine:

relpath-test % quarto render report1/report.qmd 

For the alternative outcome,

Modify font-path by removing /. Then modify the call in the terminal:

report1 % quarto render report.qmd 

Actual behavior

The pdf document is created, but the text is using the default font.
Image

Expected behavior

The pdf should be created using the updated font based on the location of the _quarto.yml and the font-path: /artifacts/.fonts.

Note that if I remove the / from the font-path, cd into report1 then call quarto render report.qmd I get the expected result:

Image

Your environment

-IDE: None, native terminal
-OS: MacOS Sequoia 15.4.1

Quarto check output

Note that the behavior can be reproduced on Quarto 1.5.55, and 1.5.57

Quarto 1.5.52
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.2.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.5.52
      Path: /Applications/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: (external install)
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /Users/htbunn/Library/TinyTeX/bin/universal-darwin
      Version: 2021

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.9.6
      Path: /Library/Developer/CommandLineTools/usr/bin/python3
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with python3 -m pip install jupyter

[✓] Checking R installation...........OK
      Version: 4.3.1
      Path: /Library/Frameworks/R.framework/Resources
      LibPaths:
        - /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library
      knitr: 1.43
      rmarkdown: 2.22

[✓] Checking Knitr engine render......OK
@htbunn htbunn added the bug Something isn't working label May 6, 2025
@cderv
Copy link
Collaborator

cderv commented May 6, 2025

Thank for reporting - we'll look into that. We know the prefix / for relative-to-quarto-project path does not work everywhere yet.

I noticed that the font-path I provided in _extension.yml was not being resolved as expected.

About this, resources in extension will be resolved a bit differently: Path relative to the extension folder should be made relative to the project on resolution. I would not expect using a path starting with '/' in an extension, so if you have a link to your extension, I would be curious to give a look at.

@cderv cderv added the typst label May 6, 2025
@mcanouil mcanouil added the extensions relates to Quarto extensions mechanism label May 6, 2025
@htbunn
Copy link
Author

htbunn commented May 6, 2025

Thank for reporting - we'll look into that.

Thank you!

Path relative to the extension folder should be made relative to the project on resolution... if you have a link to your extension, I would be curious to give a look at.

The extension is part of a larger internal project, which I can't link to, but I made another example repo with the same basic setup. Interestingly enough, your comment about the path being made relative on resolution helped me address the issue for this part (I think). I changed font-path to .font which sits in the same directory as _extension.yml, and the font appeared as intended.

I'm not sure why, but when I call quarto add htbunn/quarto-relpath-typst in a new, empty directory, the template.qmd and _quarto.yml aren't added along with the other files. I just added them to the root manually.

_quarto.yml:

title: "Quarto Relpath Typst Example"
format:
  relpath-typst: default

template.qmd:

Testing my text.

Then called:

mytestreport2 % quarto render template.qmd

@cderv
Copy link
Collaborator

cderv commented May 7, 2025

Interestingly enough, your comment about the path being made relative on resolution helped me address the issue for this part (I think). I changed font-path to .font which sits in the same directory as _extension.yml, and the font appeared as intended.

Great - this is how resources in extensions are supposed to be used.

I'm not sure why, but when I call quarto add htbunn/quarto-relpath-typst in a new, empty directory, the template.qmd and _quarto.yml aren't added along with the other files. I just added them to the root manually.

quarto add will install the extension. Installing the extension will only the _extensions folder.
If template.qmd is meant to be a starter template, then the command is different: quarto use template
See https://quarto.org/docs/extensions/starter-templates.html and https://quarto.org/docs/extensions/starter-templates.html#extensions-templates

So for example

  • quarto use template quarto-journals/acm will install the template and the extension that goes with it
    This is usually useful for Custom formats for example

  • quarto add quarto-journals/acm will only add the extension.
    This can be useful in an existing project, or to only use part of the extension contribution in an existing project.

_quarto.yml is something different here, as it is usually part of Starter template for Project Type extension: https://quarto.org/docs/extensions/project-types.html#starter-template

But command is the same quarto use template

Hope it clarifies the difference.

@cderv cderv removed the extensions relates to Quarto extensions mechanism label May 7, 2025
@cderv cderv self-assigned this May 7, 2025
@cderv cderv added this to the v1.8 milestone May 7, 2025
@gordonwoodhull gordonwoodhull self-assigned this May 7, 2025
@htbunn
Copy link
Author

htbunn commented May 7, 2025

Hope it clarifies the difference.

It does, indeed. Thank you!

@cderv cderv removed their assignment May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working typst
Projects
None yet
Development

No branches or pull requests

4 participants