make ezgui build on wasm again, after fontdb changes. not running though...
@@ -4,7 +4,9 @@ use geom::Bounds;
use lru::LruCache;
use std::cell::RefCell;
use std::collections::HashMap;
-use usvg::{fontdb, Options};
+#[cfg(not(feature = "wasm-backend"))]
+use usvg::fontdb;
+use usvg::Options;
// TODO We don't need refcell maybe? Can we take &mut Assets?
pub struct Assets {
@@ -15,6 +17,7 @@ pub struct Assets {
// Keyed by filename, then scale factor mangled into a hashable form. Tuple doesn't work
// because of borrowing.
svg_cache: RefCell<HashMap<String, HashMap<usize, (GeomBatch, Bounds)>>>,
+ #[cfg(not(feature = "wasm-backend"))]
font_to_id: HashMap<Font, fontdb::ID>,
pub text_opts: Options,
}
@@ -27,9 +30,12 @@ impl Assets {
text_cache: RefCell::new(LruCache::new(500)),
line_height_cache: RefCell::new(HashMap::new()),
svg_cache: RefCell::new(HashMap::new()),
+ #[cfg(not(feature = "wasm-backend"))]
font_to_id: HashMap::new(),
text_opts: Options::default(),
};
+ #[cfg(not(feature = "wasm-backend"))]
+ {
a.text_opts.fontdb = fontdb::Database::new();
a.text_opts.fontdb.load_fonts_dir(font_dir);
for font in vec![
@@ -59,6 +65,7 @@ impl Assets {
}
*a.default_line_height.borrow_mut() =
a.line_height(text::DEFAULT_FONT, text::DEFAULT_FONT_SIZE);
+ }
a
}
