Skip to content
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

More control over typst compilation environment #3892

Closed
tingerrr opened this issue Apr 7, 2024 · 6 comments · Fixed by #4227
Closed

More control over typst compilation environment #3892

tingerrr opened this issue Apr 7, 2024 · 6 comments · Fixed by #4227
Assignees
Labels
cli About Typst's command line interface. feature request New feature or request

Comments

@tingerrr
Copy link
Contributor

tingerrr commented Apr 7, 2024

Description

To improve reproducibility across systems compiling a Typst document, it would be beneficial to have complete control over the parts of the compilation environment which are implicitly used.

The following things are implicitly taken and not part of inputs of the typst binary:

  • fonts
    • $TYPST_FONTS + system fonts
  • package data directory
    • $XDG_DATA_HOME
    • $HOME/.local/share/typst
  • package cache directory
    • $XDG_CACHE_HOME
    • $HOME/.cache/typst

TYPST_FONTS is currently additive, there is no way to configured Typst to not include system fonts to my knowledge. It would be great if this was not additive, but an absolute configuration of how to retrieve fonts, allowing the user to simply append the system directories if needed.

Setting XDG_DATA_DIR/XDG_CACHE_DIR can have side effects on other programs run in the same context as Typst. While they are good fallbacks, there should be a first-class TYPST_* environment variable for the respective package cache and package data directories which is considered first before fallback to the respective $XDG_*/typst occurs.

During discussion about this in the Typst community discord, it was suggested that these should, similar to other options, also be optional compiler flags.

Use Case

This aids in isolating the effect of environment variables on the rest of the system and helps reproducibility by removing implicit assumptions on the compilation environment.

@tingerrr tingerrr added the feature request New feature or request label Apr 7, 2024
@drupol
Copy link
Sponsor Contributor

drupol commented Apr 7, 2024

Thank you for considering my request!

@alerque
Copy link
Contributor

alerque commented Apr 8, 2024

In general this is a great goal, total control of the inputs and reproducibility of the outputs is fantastic. Just a nit though, for usability's sake the easiest to reach for options don't necessarily have to have this goal in mind. Specifically fonts, I think most people will want the fonts option to be additive to the system default, so a specific extra option to only use directly specified locations might be called for.

@laurmaedje laurmaedje added the cli About Typst's command line interface. label Apr 13, 2024
@tingerrr
Copy link
Contributor Author

I know this is fresh, but I want to add a simple motivating example:

In preparation for releasing subpar, I added tests which, unknowingly to me, used font fallback (which is fine) to a system font (which was not fine).

Being only caught in CI, where no font was missing, took me a while to debug. If I could remove all system fonts and only used built ins, then I would've noticed the lack of CJK glyphs in my test locally already.

@7sDream
Copy link
Contributor

7sDream commented Apr 21, 2024

Not using system fonts is helpful for controlling the final result. Most of my projects currently have a dedicated font folder in the project directory. I think it would be useful to have an option to completely disable system font search.

Maybe a CLI option, like --no-system-fonts?

@PgBiel
Copy link
Contributor

PgBiel commented Apr 24, 2024

Maybe a CLI option, like --no-system-fonts?

Sounds like an idea, I think an env var for this wouldn't be very appropriate

@PgBiel
Copy link
Contributor

PgBiel commented May 7, 2024

Working on this by the way 🙂

(Sorry to other interested contributors for not mentioning this very explicitly earlier - that was why I was assigned)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli About Typst's command line interface. feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants