diff --git a/example-book/src/chapter_2.md b/example-book/src/chapter_2.md index 5d046a3..4aa4d1c 100644 --- a/example-book/src/chapter_2.md +++ b/example-book/src/chapter_2.md @@ -26,4 +26,12 @@ It uses external Typst that should be installed in path, so you can use packages domain: (-calc.pi, calc.pi), x => calc.cos((x + calc.pi) * 1rad)) }) }) +``` + +```typ +$integral_a^b x^2$ + +#show math.equation: set text(font: "Fira Math", fallback: false) + +$integral_a^b x^2$ ``` \ No newline at end of file diff --git a/example-book/src/fonts/FiraMath-Regular.otf b/example-book/src/fonts/FiraMath-Regular.otf new file mode 100644 index 0000000..f1f9d40 Binary files /dev/null and b/example-book/src/fonts/FiraMath-Regular.otf differ diff --git a/src/lib.rs b/src/lib.rs index f44b4bb..a0e6ec6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -162,6 +162,7 @@ fn process_chapter( let (file, err) = render_block( text, chapter_path.clone(), + build_dir.clone(), chapter.name.clone(), !lang.contains("nopreamble"), ); @@ -297,6 +298,7 @@ fn sha256_hash(input: &str) -> String { fn render_block( src: String, mut dir: PathBuf, + mut build_dir: PathBuf, name: String, preamble: bool, ) -> (String, Option>) { @@ -319,13 +321,21 @@ fn render_block( }; write!(file, "{}", src).expect("Error writing to file"); - let res = Command::new("typst") + let mut res = Command::new("typst"); + let mut res = res .arg("c") .arg(&dir) .arg("--root") .arg(dir.parent().unwrap().parent().unwrap()) - .arg(&output) - .output(); + .arg(&output); + + build_dir.push("fonts"); + + if build_dir.exists() { + res = res.arg("--font-path").arg(build_dir) + } + + let res = res.output(); command = Some(async move { let output = res.await.expect("Failed").stderr;