Shaper includes system symbol fonts into cache

This should fix #153 on Windows but needs testing on Linux and macOS.
macos-click-through
Raffael Zica 5 years ago
parent 6451f7e736
commit 0b301cb690

@ -16,6 +16,15 @@ const EMOJI_FONT: &str = "NotoColorEmoji.ttf";
const WIDE_FONT: &str = "NotoSansMonoCJKjp-Regular.otf"; const WIDE_FONT: &str = "NotoSansMonoCJKjp-Regular.otf";
const WIDE_BOLD_FONT: &str = "NotoSansMonoCJKjp-Bold.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")] #[cfg(target_os = "windows")]
const SYSTEM_EMOJI_FONT: &str = "Segoe UI Emoji"; const SYSTEM_EMOJI_FONT: &str = "Segoe UI Emoji";
@ -25,6 +34,7 @@ const SYSTEM_EMOJI_FONT: &str = "Apple Color Emoji";
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
const SYSTEM_EMOJI_FONT: &str = "Noto Color Emoji"; const SYSTEM_EMOJI_FONT: &str = "Noto Color Emoji";
#[derive(RustEmbed)] #[derive(RustEmbed)]
#[folder = "assets/fonts/"] #[folder = "assets/fonts/"]
struct Asset; 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)); 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")) { if cfg!(not(target_os = "macos")) {
let emoji_data = Asset::get(EMOJI_FONT).expect("Failed to read emoji font data"); 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"); let emoji_font = Font::from_bytes(emoji_data.to_vec().into(), 0).expect("Failed to parse emoji font data");

Loading…
Cancel
Save