From 0c1a7029e316fe6dbb52253a3dd20ea4982c0223 Mon Sep 17 00:00:00 2001 From: Lucas Miranda <4644436+lucas-miranda@users.noreply.github.com> Date: Thu, 29 Jul 2021 01:18:19 -0300 Subject: [PATCH] Fix to ensure provided gui font is valid (#842) Providing a wrong font was causing neovide to retry every time to load an inexistent font, instead just trying to load once at it's setup should be enough --- src/renderer/fonts/caching_shaper.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/renderer/fonts/caching_shaper.rs b/src/renderer/fonts/caching_shaper.rs index 076c65c..206dff2 100644 --- a/src/renderer/fonts/caching_shaper.rs +++ b/src/renderer/fonts/caching_shaper.rs @@ -66,8 +66,16 @@ impl CachingShaper { pub fn update_font(&mut self, guifont_setting: &str) { trace!("Updating font: {}", guifont_setting); - self.options = FontOptions::parse(guifont_setting); - self.reset_font_loader(); + let options = FontOptions::parse(guifont_setting); + let font_key = FontKey::from(&options); + + if let Some(_) = self.font_loader.get_or_load(&font_key) { + trace!("Font updated to: {}", guifont_setting); + self.options = options; + self.reset_font_loader(); + } else { + trace!("Font can't be updated to: {}", guifont_setting); + } } fn reset_font_loader(&mut self) {