From 0b301cb69007316e8588444ddd57d56a88b6ce1d Mon Sep 17 00:00:00 2001 From: Raffael Zica <1042414+SirJson@users.noreply.github.com> Date: Thu, 27 Feb 2020 16:55:34 +0100 Subject: [PATCH] Shaper includes system symbol fonts into cache This should fix #153 on Windows but needs testing on Linux and macOS. --- src/renderer/caching_shaper.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/renderer/caching_shaper.rs b/src/renderer/caching_shaper.rs index a8c25a7..97ef84b 100644 --- a/src/renderer/caching_shaper.rs +++ b/src/renderer/caching_shaper.rs @@ -16,6 +16,15 @@ const EMOJI_FONT: &str = "NotoColorEmoji.ttf"; const WIDE_FONT: &str = "NotoSansMonoCJKjp-Regular.otf"; const WIDE_BOLD_FONT: &str = "NotoSansMonoCJKjp-Bold.otf"; +#[cfg(target_os = "windows")] +const SYSTEM_SYMBOL_FONT: &str = "Segoe UI Symbol"; + +#[cfg(target_os = "linux")] +const SYSTEM_SYMBOL_FONT: &str = "Unifont"; + +#[cfg(target_os = "macos")] +const SYSTEM_SYMBOL_FONT: &str = "Apple Symbols"; + #[cfg(target_os = "windows")] const SYSTEM_EMOJI_FONT: &str = "Segoe UI Emoji"; @@ -25,6 +34,7 @@ const SYSTEM_EMOJI_FONT: &str = "Apple Color Emoji"; #[cfg(target_os = "linux")] const SYSTEM_EMOJI_FONT: &str = "Noto Color Emoji"; + #[derive(RustEmbed)] #[folder = "assets/fonts/"] struct Asset; @@ -86,6 +96,11 @@ fn build_collection_by_font_name(font_name: Option<&str>, bold: bool, italic: bo collection.add_family(FontFamily::new_from_font(font)); } + if let Ok(sys_symbol) = source.select_family_by_name(SYSTEM_SYMBOL_FONT) { + let font = sys_symbol.fonts()[0].load().unwrap(); + collection.add_family(FontFamily::new_from_font(font)); + } + if cfg!(not(target_os = "macos")) { let emoji_data = Asset::get(EMOJI_FONT).expect("Failed to read emoji font data"); let emoji_font = Font::from_bytes(emoji_data.to_vec().into(), 0).expect("Failed to parse emoji font data");