From a64553bbaf9e058f02d278dfa7104ea96fc58dd8 Mon Sep 17 00:00:00 2001 From: Greg Depoire--Ferrer <56923875+greg904@users.noreply.github.com> Date: Wed, 16 Feb 2022 20:57:46 +0000 Subject: Reuse Rasterizer in Display::new Instead of creating a `Rasterizer` to guess the window dimensions, dropping it and then creating a new one for the glyph cache, reuse the same `Rasterizer`. This prevents the font from being loaded twice during startup. --- alacritty/src/renderer/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'alacritty/src/renderer/mod.rs') diff --git a/alacritty/src/renderer/mod.rs b/alacritty/src/renderer/mod.rs index ad59a4e1..e7878b6d 100644 --- a/alacritty/src/renderer/mod.rs +++ b/alacritty/src/renderer/mod.rs @@ -404,10 +404,12 @@ impl GlyphCache { } /// Calculate font metrics without access to a glyph cache. - pub fn static_metrics(font: Font, dpr: f64) -> Result { - let mut rasterizer = crossfont::Rasterizer::new(dpr as f32, font.use_thin_strokes)?; + pub fn static_metrics( + rasterizer: &mut crossfont::Rasterizer, + font: Font, + ) -> Result { let regular_desc = GlyphCache::make_desc(font.normal(), Slant::Normal, Weight::Normal); - let regular = Self::load_regular_font(&mut rasterizer, ®ular_desc, font.size())?; + let regular = Self::load_regular_font(rasterizer, ®ular_desc, font.size())?; rasterizer.get_glyph(GlyphKey { font_key: regular, character: 'm', size: font.size() })?; rasterizer.metrics(regular, font.size()) -- cgit