Files
VoelinClient/crates/voelin-gpui/src/fonts.rs
T
faumarayandClaude Sonnet 5.5 8f3d809e8a voelin-gpui: fonts.rs points at the report's "Open choices for step 3", which exist
The module comment sent the colour emoji to docs/design/gpui-spikes.md,
"Emoji", a section the report does not have (the colour emoji gap is a
paragraph of spike 2, and the choice is under "Open choices for step 3"): the
same dangling pointer docs/ui.md had in the slice 4 line, found by grep in the
round that fixed that one.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-27 13:49:15 +03:00

40 lines
1.4 KiB
Rust

//! 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<Cow<'static, [u8]>> = 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");
}
}
}