Read font path from environment variables (#649)

This commit is contained in:
Michael Lohr 2023-04-12 19:03:12 +02:00 committed by GitHub
parent e4fda4176e
commit 8300f75f22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -149,6 +149,9 @@ typst --font-path path/to/fonts compile file.typ
# Lists all of the discovered fonts in the system and the given directory.
typst --font-path path/to/fonts fonts
# Or via environement variable (Linux syntax).
TYPST_FONT_PATHS=path/to/fonts typst fonts
```
If you prefer an integrated IDE-like experience with autocompletion and instant

View File

@ -32,7 +32,7 @@ once_cell = "1"
same-file = "1"
siphasher = "0.3"
walkdir = "2"
clap = { version = "4.2.1", features = ["derive"] }
clap = { version = "4.2.1", features = ["derive", "env"] }
open = "4.0.1"
[build-dependencies]

View File

@ -7,11 +7,11 @@ use clap::{ArgAction, Parser, Subcommand};
#[clap(name = "typst", version = crate::typst_version(), author)]
pub struct CliArguments {
/// Add additional directories to search for fonts
#[clap(long = "font-path", value_name = "DIR", action = ArgAction::Append)]
#[clap(long = "font-path", env = "TYPST_FONT_PATHS", value_name = "DIR", action = ArgAction::Append)]
pub font_paths: Vec<PathBuf>,
/// Configure the root for absolute paths
#[clap(long = "root", value_name = "DIR")]
#[clap(long = "root", env = "TYPST_ROOT", value_name = "DIR")]
pub root: Option<PathBuf>,
/// The typst command to run