diff --git a/wezterm-font/src/lib.rs b/wezterm-font/src/lib.rs index 90f4cce26..b3fb32101 100644 --- a/wezterm-font/src/lib.rs +++ b/wezterm-font/src/lib.rs @@ -15,7 +15,7 @@ use std::ops::Range; use std::rc::{Rc, Weak}; use std::sync::mpsc::{channel, Sender}; use std::sync::{Arc, Mutex}; -use std::time::Duration; +use std::time::{Duration, Instant}; use termwiz::cell::Presentation; use thiserror::Error; use wezterm_bidi::Direction; @@ -48,6 +48,10 @@ pub fn alloc_font_id() -> LoadedFontId { FONT_ID.fetch_add(1, ::std::sync::atomic::Ordering::Relaxed) } +lazy_static::lazy_static! { + static ref LAST_WARNING: Mutex> = Mutex::new(None); +} + pub struct LoadedFont { rasterizers: RefCell>>, handles: RefCell>, @@ -392,7 +396,15 @@ impl FallbackResolveInfo { .map(|c| std::char::from_u32(c).unwrap_or(' ')) .collect::(); - if self.config.warn_about_missing_glyphs { + let show_warning = self.config.warn_about_missing_glyphs + && LAST_WARNING + .lock() + .unwrap() + .map(|instant| instant.elapsed() > Duration::from_secs(60 * 60)) + .unwrap_or(true); + + if show_warning { + LAST_WARNING.lock().unwrap().replace(Instant::now()); let url = "https://wezfurlong.org/wezterm/config/fonts.html"; log::warn!( "No fonts contain glyphs for these codepoints: {}.\n\