Merge pull request #155 from SirJson/system-symbol-fonts

Shaper includes system symbol fonts into cache
macos-click-through
Keith Simmons 5 years ago committed by GitHub
commit 1e980689b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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");

Loading…
Cancel
Save