Skip to content

Commit

Permalink
fix fallback font selection regression
Browse files Browse the repository at this point in the history
- apparently the fallback font is now drawn from the asset FontMgr rather than the system FontMgr, meaning the first font added via `FontLibrary.use` will be selected if the `ctx.font` family has no matches
- now querying the system FontMgr for its default font then using that as a fallback
  • Loading branch information
samizdatco committed Oct 27, 2024
1 parent fbd13c2 commit f649c82
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/typography.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl Typesetter{
//
// Font argument packing & unpacking
//

#[derive(Debug)]
pub struct FontSpec{
families: Vec<String>,
size: f32,
Expand Down Expand Up @@ -476,13 +476,17 @@ impl FontLibrary{
}
self.fonts.push((font, alias));

let sys_mgr = FontMgr::new();
let default_fam = sys_mgr.legacy_make_typeface(None, FontStyle::default())
.map(|f| f.family_name());

let mut assets = TypefaceFontProvider::new();
for (font, alias) in &self.fonts {
assets.register_typeface(font.clone(), alias.as_deref());
}

let mut collection = FontCollection::new();
collection.set_default_font_manager(FontMgr::new(), None);
collection.set_default_font_manager(sys_mgr, default_fam.as_deref());
collection.set_asset_font_manager(Some(assets.into()));
self.collection = collection;
self.collection_cache.drain();
Expand Down

0 comments on commit f649c82

Please sign in to comment.