diff --git a/wezterm-font/src/lib.rs b/wezterm-font/src/lib.rs index b12fd37eb..5dd253a78 100644 --- a/wezterm-font/src/lib.rs +++ b/wezterm-font/src/lib.rs @@ -126,14 +126,14 @@ impl LoadedFont { } if extra_handles.is_empty() { - log::warn!("No fonts have glyphs for {}", fallback_str.escape_debug()); + font_config.advise_no_glyphs(&fallback_str); } else { let loaded = self.insert_fallback_handles(extra_handles)?; if loaded { log::trace!("handles is now: {:#?}", self.handles); return self.shape(text); } else { - log::warn!("No fonts have glyphs for {}", fallback_str.escape_debug()) + font_config.advise_no_glyphs(&fallback_str); } } } @@ -180,6 +180,7 @@ struct FontConfigInner { locator: Box, font_dirs: RefCell, built_in: RefCell, + no_glyphs: RefCell>, } /// Matches and loads fonts for a given input style @@ -201,6 +202,7 @@ impl FontConfigInner { config: RefCell::new(config.clone()), font_dirs: RefCell::new(FontDatabase::with_font_dirs(&config)?), built_in: RefCell::new(FontDatabase::with_built_in()?), + no_glyphs: RefCell::new(HashSet::new()), }) } @@ -210,10 +212,30 @@ impl FontConfigInner { // Config was reloaded, invalidate our caches fonts.clear(); self.metrics.borrow_mut().take(); + self.no_glyphs.borrow_mut().clear(); *self.font_dirs.borrow_mut() = FontDatabase::with_font_dirs(config)?; Ok(()) } + fn advise_no_glyphs(&self, fallback_str: &str) { + let mut no_glyphs = self.no_glyphs.borrow_mut(); + let mut notif = String::new(); + for c in fallback_str.chars() { + if !no_glyphs.contains(&c) { + notif.push(c); + no_glyphs.insert(c); + } + } + if !notif.is_empty() { + mux::connui::show_configuration_error_message(&format!( + "Unable to resolve a font containing glyphs for {}. \ + A glyph from the built-in \"last resort\" font is being \ + used instead.", + notif.escape_unicode() + )); + } + } + /// Given a text style, load (with caching) the font that best /// matches according to the fontconfig pattern. fn resolve_font(&self, myself: &Rc, style: &TextStyle) -> anyhow::Result> {