diff --git a/Cargo.lock b/Cargo.lock index 55d5d71..d0d884f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1151,6 +1151,7 @@ version = "0.5.0" dependencies = [ "anyhow", "async-trait", + "cfg-if", "derive-new", "euclid", "flexi_logger", diff --git a/Cargo.toml b/Cargo.toml index 0fd7893..6a4810f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ log = "0.4.8" flexi_logger = { version = "0.14.6", default-features = false } anyhow = "1.0.26" parking_lot="0.10.0" +cfg-if = "0.1.10" [target.'cfg(windows)'.dependencies] winapi = "0.3.8" diff --git a/src/renderer/caching_shaper.rs b/src/renderer/caching_shaper.rs index 1389756..d4e56f9 100644 --- a/src/renderer/caching_shaper.rs +++ b/src/renderer/caching_shaper.rs @@ -16,35 +16,27 @@ use log::{info, trace, warn}; const STANDARD_CHARACTER_STRING: &str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; -#[cfg(target_os = "windows")] +cfg_if::cfg_if! { + if #[cfg(target_os = "windows")] { const SYSTEM_DEFAULT_FONT: &str = "Consolas"; - -#[cfg(target_os = "linux")] -const SYSTEM_DEFAULT_FONT: &str = "Droid Sans Mono"; - -#[cfg(target_os = "macos")] -const SYSTEM_DEFAULT_FONT: &str = "Menlo"; - -#[cfg(target_os = "windows")] const SYSTEM_SYMBOL_FONT: &str = "Segoe UI Symbol"; + const SYSTEM_EMOJI_FONT: &str = "Segoe UI Emoji"; -#[cfg(target_os = "linux")] + } else if #[cfg(target_os = "linux")] { + const SYSTEM_DEFAULT_FONT: &str = "Droid Sans Mono"; const SYSTEM_SYMBOL_FONT: &str = "Unifont"; + const SYSTEM_EMOJI_FONT: &str = "Noto Color Emoji"; -#[cfg(target_os = "macos")] -const SYSTEM_SYMBOL_FONT: &str = "Apple Symbols"; - -#[cfg(target_os = "windows")] -const SYSTEM_EMOJI_FONT: &str = "Segoe UI Emoji"; -#[cfg(target_os = "macos")] + } else if #[cfg(target_os = "macos")] { + const SYSTEM_DEFAULT_FONT: &str = "Menlo"; + const SYSTEM_SYMBOL_FONT: &str = "Apple Symbols"; const SYSTEM_EMOJI_FONT: &str = "Apple Color Emoji"; + } +} -#[cfg(target_os = "linux")] -const SYSTEM_EMOJI_FONT: &str = "Noto Color Emoji"; - -const SYMBOL_FONT: &str = "Extra Symbols.otf"; -const MISSING_GLYPHS_FONT: &str = "Missing Glyphs.otf"; +const EXTRA_SYMBOL_FONT: &str = "Extra Symbols.otf"; +const MISSING_GLYPH_FONT: &str = "Missing Glyphs.otf"; #[cfg(feature = "embed-fonts")] #[derive(RustEmbed)]