pub const TEXT_SIZE: f32 = 12.5;
pub const SMALL_TEXT_SIZE: f32 = 11.5;
pub const TITLE_TEXT_SIZE: f32 = 14.0;
pub fn ui_font() -> &'static str {
if cfg!(target_os = "macos") {
".SystemUIFont"
} else if cfg!(target_os = "windows") {
"Segoe UI"
} else {
"sans-serif"
}
}
pub fn symbol_fonts() -> &'static [&'static str] {
if cfg!(target_os = "macos") {
&["Apple Symbols", "Menlo"]
} else if cfg!(target_os = "windows") {
&["Segoe UI Symbol", "Segoe UI Emoji"]
} else {
&["DejaVu Sans", "Noto Sans Symbols 2", "Noto Sans Symbols"]
}
}
pub fn ui_font_face() -> gpui::Font {
gpui::Font {
fallbacks: Some(gpui::FontFallbacks::from_fonts(
symbol_fonts().iter().map(|face| face.to_string()).collect(),
)),
..gpui::font(ui_font())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn the_interface_face_falls_back_to_the_symbol_faces_in_order() {
let face = ui_font_face();
assert_eq!(face.family.as_ref(), ui_font());
let fallbacks = face
.fallbacks
.expect("symbol faces behind the interface face");
assert_eq!(fallbacks.fallback_list(), symbol_fonts());
}
}