Handle the case where configured font name is not available

This can happen if configured font name is uninstalled for example.

 Pick the first font name available if that's the case.

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
This commit is contained in:
Mohammad AlSaleh 2024-01-02 18:23:44 +03:00 committed by Jeremy Soller
parent 5eba6eb4d6
commit 59804dc8ab

View file

@ -247,6 +247,14 @@ impl App {
}
fn set_curr_font_weights_and_stretches(&mut self) {
// check if config font_name is available first, if not, set it to first name in list
if !self.font_names.contains(&self.config.font_name) {
log::error!("'{}' is not in the font list", self.config.font_name);
log::error!("setting font name to '{}'", self.font_names[0]);
self.config.font_name = self.font_names[0].clone();
let _ = self.save_config();
}
let curr_font_faces = &self.font_name_faces_map[&self.config.font_name];
self.curr_font_stretches = curr_font_faces