Skip to content

Commit e89c6df

Browse files
committed
recreate the FontCollection with every modification
- previously, the asset-manager was replaced but the parent FontCollection persisted across calls to .use and .reset - apparently it was still caching old fonts rather than querying the asset manager each time - fixes samizdatco#94
1 parent 2a75801 commit e89c6df

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/typography.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,10 @@ impl FontLibrary{
482482
assets.register_typeface(font.clone(), alias.as_ref());
483483
}
484484

485-
self.collection.set_asset_font_manager(Some(assets.into()));
485+
let mut collection = FontCollection::new();
486+
collection.set_default_font_manager(FontMgr::new(), None);
487+
collection.set_asset_font_manager(Some(assets.into()));
488+
self.collection = collection;
486489
self.collection_cache.drain();
487490
}
488491

@@ -649,5 +652,11 @@ pub fn addFamily(mut cx: FunctionContext) -> JsResult<JsValue> {
649652
pub fn reset(mut cx: FunctionContext) -> JsResult<JsUndefined> {
650653
let mut library = FONT_LIBRARY.lock().unwrap();
651654
library.fonts.clear();
655+
656+
let mut collection = FontCollection::new();
657+
collection.set_default_font_manager(FontMgr::new(), None);
658+
library.collection = collection;
659+
library.collection_cache.drain();
660+
652661
Ok(cx.undefined())
653662
}

0 commit comments

Comments
 (0)