Check font size to prevent crash

This commit is contained in:
daa 2018-05-12 11:48:17 +03:00
parent dfde1f46bb
commit 1a0aee2f89
1 changed files with 8 additions and 1 deletions

View File

@ -264,8 +264,15 @@ impl State {
}
pub fn set_font_desc(&mut self, desc: &str) {
let font_description = FontDescription::from_string(desc);
if font_description.get_size() <= 0 {
error!("Font size must be > 0");
return;
}
let pango_context = self.drawing_area.create_pango_context().unwrap();
pango_context.set_font_description(&FontDescription::from_string(desc));
pango_context.set_font_description(&font_description);
self.render_state
.borrow_mut()