diff --git a/wezterm-font/src/shaper/harfbuzz.rs b/wezterm-font/src/shaper/harfbuzz.rs index 1a4ec31b1..c948b17a1 100644 --- a/wezterm-font/src/shaper/harfbuzz.rs +++ b/wezterm-font/src/shaper/harfbuzz.rs @@ -693,7 +693,7 @@ impl FontShaper for HarfbuzzShaper { fn metrics_for_idx(&self, font_idx: usize, size: f64, dpi: u32) -> anyhow::Result { let mut pair = self .load_fallback(font_idx)? - .ok_or_else(|| anyhow!("unable to load font idx {}!?", font_idx))?; + .ok_or_else(|| anyhow!("metrics_for_idx: there is no font with idx={font_idx}!?"))?; let key = MetricsKey { font_idx, @@ -796,6 +796,21 @@ impl FontShaper for HarfbuzzShaper { theoretical_height, selected_size.height ); + + if metrics_idx + 1 >= self.handles.len() { + log::warn!( + "metrics: I wanted to skip idx {} because diff={} factor={} \ + theoretical_height={} cell_height={}, but there are no more \ + fallback fonts. Metrics will likely be crazy.", + metrics_idx, + diff, + factor, + theoretical_height, + selected_size.height + ); + break; + } + metrics_idx += 1; }