Skip to content

Commit 767fcb1

Browse files
authored
Fix math font url (#52)
The math font url wasn't resolved by Vite, so we now import it using [Explicit URL Imports](https://vite.dev/guide/assets#explicit-url-imports).
1 parent 3beaa70 commit 767fcb1

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

web/src/typst.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import type * as typstWeb from "@myriaddreamin/typst.ts";
99
import { createTypstCompiler, createTypstRenderer } from "@myriaddreamin/typst.ts";
1010
import { disableDefaultFontAssets, loadFonts } from "@myriaddreamin/typst.ts/dist/esm/options.init.mjs";
1111

12+
// @ts-expect-error ?url import
13+
import mathFontUrl from "/math-font.ttf?url";
14+
1215
// @ts-expect-error WASM module import
1316
import typstCompilerWasm from "@myriaddreamin/typst-ts-web-compiler/pkg/typst_ts_web_compiler_bg.wasm?url";
1417
// @ts-expect-error WASM module import
@@ -37,9 +40,8 @@ async function initCompiler() {
3740
getModule: () => typstCompilerWasm,
3841
beforeBuild: [
3942
disableDefaultFontAssets(),
40-
loadFonts([
41-
"/math-font.ttf",
42-
]),
43+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
44+
loadFonts([mathFontUrl]),
4345
],
4446
});
4547
console.log("Typst compiler initialized");

0 commit comments

Comments
 (0)