From 99074c6dc3a6492c00603748e36ce0f7321a0de4 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Wed, 11 Aug 2021 22:37:07 -0700 Subject: [PATCH] font: avoid running out of fallbacks! The recent presentation logic needs to be tweaked to ensure that we ignore presentation when we reach the fallback font, otherwise we'll end up in a bad error stack and crash the program. --- wezterm-font/src/shaper/harfbuzz.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/wezterm-font/src/shaper/harfbuzz.rs b/wezterm-font/src/shaper/harfbuzz.rs index 7437d9559..836a18190 100644 --- a/wezterm-font/src/shaper/harfbuzz.rs +++ b/wezterm-font/src/shaper/harfbuzz.rs @@ -190,10 +190,13 @@ impl HarfbuzzShaper { loop { match self.load_fallback(font_idx).context("load_fallback")? { Some(mut pair) => { - if let Some(p) = presentation { - if pair.presentation != p { - font_idx += 1; - continue; + // Ignore presentation if we've reached the last resort font + if font_idx + 1 < self.fonts.len() { + if let Some(p) = presentation { + if pair.presentation != p { + font_idx += 1; + continue; + } } } let size = pair.face.set_font_size(font_size, dpi)?;