Skip to content

More control over typst compilation environment #3892

Closed

Description

@tingerrr

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.

Activity

  1. added
    feature request
    on Apr 7, 2024
  2. drupol commented on Apr 7, 2024

    @drupol
    Contributor

    Thank you for considering my request!

  3. alerque commented on Apr 8, 2024

    @alerque
    Contributor

    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.

  4. added
    cli
    on Apr 13, 2024
  5. tingerrr commented on Apr 21, 2024

    @tingerrr
    ContributorAuthor

    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.

  6. 7sDream commented on Apr 21, 2024

    @7sDream
    Contributor

    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?

  7. PgBiel commented on Apr 24, 2024

    @PgBiel
    Contributor

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

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

  8. PgBiel commented on May 7, 2024

    @PgBiel
    Contributor

    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

Metadata

Metadata

Assignees

Labels

clifeature request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions