From 261a27091b5f78d8f47cadaaefe90a0c9ad9f695 Mon Sep 17 00:00:00 2001 From: exoticus <56480961+exoticus@users.noreply.github.com> Date: Fri, 17 Apr 2020 00:23:40 +0200 Subject: [PATCH] not disgusting any more, should also patch variants --- src/renderer/caching_shaper.rs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/renderer/caching_shaper.rs b/src/renderer/caching_shaper.rs index 2b3f3fe..3054723 100644 --- a/src/renderer/caching_shaper.rs +++ b/src/renderer/caching_shaper.rs @@ -165,17 +165,22 @@ pub fn build_collection_by_font_name( let mut collection = FontCollection::new(); if let Some(font_name) = font_name { - if let Some(family) = loader.get_or_load(font_name, false) { - let weight = if bold { Weight::BOLD } else { Weight::NORMAL }; - let style = if italic { Style::Italic } else { Style::Normal }; - let properties = Properties { - weight, - style, - stretch: Stretch::NORMAL, - }; - - if let Some(font) = family.get(properties) { - collection.add_family(FontFamily::new_from_font(font.clone())); + let weight = if bold { Weight::BOLD } else { Weight::NORMAL }; + let style = if italic { Style::Italic } else { Style::Normal }; + let properties = Properties { + weight, + style, + stretch: Stretch::NORMAL, + }; + + let gui_fonts = &[font_name, SYSTEM_DEFAULT_FONT]; + + for font_name in gui_fonts { + if let Some(family) = loader.get_or_load(font_name, false) { + if let Some(font) = family.get(properties) { + collection.add_family(FontFamily::new_from_font(font.clone())); + break; + } } } }