diff --git a/wezterm-font/src/ftwrap.rs b/wezterm-font/src/ftwrap.rs index ac6b05914..a7209bde2 100644 --- a/wezterm-font/src/ftwrap.rs +++ b/wezterm-font/src/ftwrap.rs @@ -172,10 +172,11 @@ impl Face { }, (), ) + .context("FT_Set_Char_Size") } fn select_size(&mut self, idx: usize) -> anyhow::Result<()> { - ft_result(unsafe { FT_Select_Size(self.face, idx as i32) }, ()) + ft_result(unsafe { FT_Select_Size(self.face, idx as i32) }, ()).context("FT_Select_Size") } pub fn load_and_render_glyph( @@ -185,9 +186,18 @@ impl Face { render_mode: FT_Render_Mode, ) -> anyhow::Result<&FT_GlyphSlotRec_> { unsafe { - let res = FT_Load_Glyph(self.face, glyph_index, load_flags); - let slot = ft_result(res, &mut *(*self.face).glyph)?; - ft_result(FT_Render_Glyph(slot, render_mode), slot) + ft_result(FT_Load_Glyph(self.face, glyph_index, load_flags), ()).with_context( + || { + anyhow!( + "load_and_render_glyph: FT_Load_Glyph glyph_index:{}", + glyph_index + ) + }, + )?; + let slot = &mut *(*self.face).glyph; + ft_result(FT_Render_Glyph(slot, render_mode), ()) + .context("load_and_render_glyph: FT_Render_Glyph")?; + Ok(slot) } } @@ -323,6 +333,9 @@ impl Library { } pub fn set_lcd_filter(&mut self, filter: FT_LcdFilter) -> anyhow::Result<()> { - unsafe { ft_result(FT_Library_SetLcdFilter(self.lib, filter), ()) } + unsafe { + ft_result(FT_Library_SetLcdFilter(self.lib, filter), ()) + .context("FT_Library_SetLcdFilter") + } } } diff --git a/wezterm-gui/src/gui/glyphcache.rs b/wezterm-gui/src/gui/glyphcache.rs index cedb5efe1..3b9f5a736 100644 --- a/wezterm-gui/src/gui/glyphcache.rs +++ b/wezterm-gui/src/gui/glyphcache.rs @@ -3,6 +3,7 @@ use ::window::bitmaps::{Image, Texture2d}; use ::window::glium::backend::Context as GliumContext; use ::window::glium::texture::SrgbTexture2d; use ::window::*; +use anyhow::{anyhow, Context}; use config::{configuration, AllowSquareGlyphOverflow, TextStyle}; use euclid::num::Zero; use std::collections::HashMap; @@ -168,7 +169,9 @@ impl GlyphCache { return Ok(Rc::clone(entry)); } - let glyph = self.load_glyph(info, style, followed_by_space)?; + let glyph = self + .load_glyph(info, style, followed_by_space) + .with_context(|| anyhow!("load_glyph {:?} {:?}", info, style))?; self.glyph_cache.insert(key.to_owned(), Rc::clone(&glyph)); Ok(glyph) }