From 87f1fedb41339ff00fb32595f95605cb55094720 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Wed, 15 Nov 2023 12:56:20 +0100 Subject: [PATCH] If `TYPST_FONT_PATHS` is set, pass it through Other our internal use of `--font-path` will override the value --- src/core/typst.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/core/typst.ts b/src/core/typst.ts index 0002c10e25..1fce6559c8 100644 --- a/src/core/typst.ts +++ b/src/core/typst.ts @@ -19,6 +19,16 @@ export function typstBinaryPath() { architectureToolsPath("typst"); } +function fontPathsArgs() { + const fontPathsEnv = Deno.env.get("TYPST_FONT_PATHS"); + const fontPathsQuarto = ["--font-path", resourcePath("formats/typst/fonts")]; + if (fontPathsEnv) { + return [...fontPathsQuarto, "--font-path", fontPathsEnv]; + } else { + return fontPathsQuarto; + } +} + export async function typstCompile( input: string, output: string, @@ -27,13 +37,11 @@ export async function typstCompile( if (!quiet) { typstProgress(input, output); } - const cmd = [ typstBinaryPath(), "compile", input, - "--font-path", - resourcePath("formats/typst/fonts"), + ...fontPathsArgs(), output, ]; const result = await execProcess({ cmd });