diff options
Diffstat (limited to 'src/display.rs')
-rw-r--r-- | src/display.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/display.rs b/src/display.rs index 25318f0e..eb562e8f 100644 --- a/src/display.rs +++ b/src/display.rs @@ -240,14 +240,15 @@ impl Display { return Ok((glyph_cache, cell_width as f32, cell_height as f32)); } - pub fn update_glyph_cache(&mut self, config: &Config, font_size_delta: i8) - { - let (glyph_cache, cell_width, cell_height) = - Self::new_glyph_cache(&self.window, - &mut self.renderer, config, font_size_delta).unwrap(); - self.glyph_cache = glyph_cache; - self.size_info.cell_width = cell_width; - self.size_info.cell_height = cell_height; + pub fn update_glyph_cache(&mut self, config: &Config, font_size_delta: i8) { + let cache = &mut self.glyph_cache; + self.renderer.with_loader(|mut api| { + let _ = cache.update_font_size(config.font(), font_size_delta, &mut api); + }); + + let metrics = cache.font_metrics(); + self.size_info.cell_width = (metrics.average_advance + config.font().offset().x as f64) as f32; + self.size_info.cell_height = (metrics.line_height + config.font().offset().y as f64) as f32; } #[inline] |