diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-01-15 16:53:02 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-01-15 16:53:02 +0100 |
| commit | d763f0f5a6a700352ee8926c15c8e58624f705c9 (patch) | |
| tree | d287edfdab9793a796404516c7313689e4e69964 /src/main.rs | |
| parent | 0f0416054f263b80ccec1a463ce4ab20913bdf71 (diff) | |
Split state and scopes, less ref-counting 🔀
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/main.rs b/src/main.rs index 4746bc0c..07eb673a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,16 +1,15 @@ -use std::cell::RefCell; use std::fs; use std::path::{Path, PathBuf}; -use std::rc::Rc; use anyhow::{anyhow, bail, Context}; -use fontdock::fs::{FsIndex, FsSource}; +use fontdock::fs::FsIndex; use typst::diag::{Feedback, Pass}; use typst::env::{Env, ResourceLoader}; use typst::eval::State; use typst::export::pdf; -use typst::font::FontLoader; +use typst::font::FsIndexExt; +use typst::library; use typst::parse::LineMap; use typst::typeset; @@ -41,17 +40,18 @@ fn main() -> anyhow::Result<()> { index.search_dir("fonts"); index.search_system(); - let (files, descriptors) = index.into_vecs(); - let env = Rc::new(RefCell::new(Env { - fonts: FontLoader::new(Box::new(FsSource::new(files)), descriptors), + let mut env = Env { + fonts: index.into_dynamic_loader(), resources: ResourceLoader::new(), - })); + }; + let scope = library::new(); let state = State::default(); + let Pass { output: frames, feedback: Feedback { mut diags, .. }, - } = typeset(&src, Rc::clone(&env), state); + } = typeset(&src, &mut env, &scope, state); if !diags.is_empty() { diags.sort(); @@ -72,7 +72,7 @@ fn main() -> anyhow::Result<()> { } } - let pdf_data = pdf::export(&frames, &env.borrow()); + let pdf_data = pdf::export(&frames, &env); fs::write(&dest_path, pdf_data).context("Failed to write PDF file.")?; Ok(()) |
