//! Inter, the UI font, as the Slint front end bundles it //! (`crates/voelin-ui/ui/assets/fonts`, OFL): the five files go into GPUI's //! text system and are used by family name ([`crate::theme::FONT_FAMILY`]), //! so nothing depends on what fontconfig finds for Latin text. Colour emoji //! come later (the chat slice; docs/design/gpui-spikes.md, "Open choices for step 3"). use std::borrow::Cow; use gpui_kit::App; /// The files of the family: regular, medium, semibold, bold, italic. const INTER: [&[u8]; 5] = [ include_bytes!("../../voelin-ui/ui/assets/fonts/Inter-Regular.ttf"), include_bytes!("../../voelin-ui/ui/assets/fonts/Inter-Medium.ttf"), include_bytes!("../../voelin-ui/ui/assets/fonts/Inter-SemiBold.ttf"), include_bytes!("../../voelin-ui/ui/assets/fonts/Inter-Bold.ttf"), include_bytes!("../../voelin-ui/ui/assets/fonts/Inter-Italic.ttf"), ]; /// Add Inter to GPUI's text system. pub fn load(cx: &mut App) { let fonts: Vec> = INTER.iter().map(|bytes| Cow::Borrowed(*bytes)).collect(); if let Err(error) = cx.text_system().add_fonts(fonts) { tracing::warn!(%error, "cannot add Inter to the text system"); } } #[cfg(test)] mod tests { use super::*; #[test] fn the_files_are_fonts() { for bytes in INTER { assert!(bytes.len() > 100_000, "a font file, not {} bytes", bytes.len()); assert!(matches!(&bytes[..4], [0, 1, 0, 0] | b"OTTO" | b"true"), "an sfnt header"); } } }