Skip to content

Commit a03c75b

Browse files
authored
Merge pull request #342 from franv314/master
Added tex directories to font searcher
2 parents 8a11ae0 + e1d0861 commit a03c75b

File tree

1 file changed

+17
-1
lines changed
  • task-maker-exec/src/execution_unit

1 file changed

+17
-1
lines changed

task-maker-exec/src/execution_unit/typst.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use zune_inflate::DeflateDecoder;
1111

1212
use std::collections::HashMap;
1313
use std::path::{Path, PathBuf};
14+
use std::process::Command;
1415
use std::sync::Arc;
1516
use std::time::Duration;
1617
use std::{env, fs};
@@ -59,7 +60,22 @@ impl TypstCompiler {
5960
})
6061
.collect::<Result<HashMap<_, _>, _>>()?;
6162

62-
let fonts = FontSearcher::new().include_system_fonts(true).search();
63+
// Try adding tex directories to the font searcher
64+
let tex_dir = Command::new("kpsewhich")
65+
.arg("-var-value=TEXMFMAIN")
66+
.output()
67+
.ok()
68+
.and_then(|output| {
69+
str::from_utf8(&output.stdout[..output.stdout.len() - 1])
70+
.ok()
71+
.map(PathBuf::from)
72+
})
73+
.into_iter()
74+
.collect::<Vec<_>>();
75+
76+
let fonts = FontSearcher::new()
77+
.include_system_fonts(true)
78+
.search_with(tex_dir);
6379

6480
let cache_dir = match env::var("XDG_CACHE_HOME") {
6581
Ok(cache) => Path::new(&cache).join("typst/packages"),

0 commit comments

Comments
 (0)