use gpui::*;
pub const UI_FONT_FAMILY: &str = "Inter";
pub const UI_MONO_FONT_FAMILY: &str = "JetBrains Mono";
#[cfg(feature = "font-inter-regular")]
const INTER_REGULAR: &[u8] = include_bytes!("../../../assets/fonts/Inter-Regular.ttf");
#[cfg(feature = "font-inter-medium")]
const INTER_MEDIUM: &[u8] = include_bytes!("../../../assets/fonts/Inter-Medium.ttf");
#[cfg(feature = "font-inter-semibold")]
const INTER_SEMIBOLD: &[u8] = include_bytes!("../../../assets/fonts/Inter-SemiBold.ttf");
#[cfg(feature = "font-inter-bold")]
const INTER_BOLD: &[u8] = include_bytes!("../../../assets/fonts/Inter-Bold.ttf");
#[cfg(feature = "font-mono-regular")]
const JETBRAINS_MONO_REGULAR: &[u8] =
include_bytes!("../../../assets/fonts/JetBrainsMono-Regular.ttf");
#[cfg(feature = "font-mono-bold")]
const JETBRAINS_MONO_BOLD: &[u8] = include_bytes!("../../../assets/fonts/JetBrainsMono-Bold.ttf");
#[allow(clippy::vec_init_then_push)]
pub fn register_fonts(cx: &mut App) {
#[allow(unused_mut)]
let mut inter_fonts: Vec<std::borrow::Cow<'static, [u8]>> = Vec::new();
#[cfg(feature = "font-inter-regular")]
inter_fonts.push(INTER_REGULAR.into());
#[cfg(feature = "font-inter-medium")]
inter_fonts.push(INTER_MEDIUM.into());
#[cfg(feature = "font-inter-semibold")]
inter_fonts.push(INTER_SEMIBOLD.into());
#[cfg(feature = "font-inter-bold")]
inter_fonts.push(INTER_BOLD.into());
if !inter_fonts.is_empty() {
if let Err(error) = cx.text_system().add_fonts(inter_fonts) {
eprintln!("fc-ui: failed to load Inter fonts, falling back to system fonts: {error}");
}
}
#[allow(unused_mut)]
let mut mono_fonts: Vec<std::borrow::Cow<'static, [u8]>> = Vec::new();
#[cfg(feature = "font-mono-regular")]
mono_fonts.push(JETBRAINS_MONO_REGULAR.into());
#[cfg(feature = "font-mono-bold")]
mono_fonts.push(JETBRAINS_MONO_BOLD.into());
if !mono_fonts.is_empty() {
if let Err(error) = cx.text_system().add_fonts(mono_fonts) {
eprintln!(
"fc-ui: failed to load JetBrains Mono fonts, falling back to system fonts: {error}"
);
}
}
}
pub fn ui_font_family() -> SharedString {
UI_FONT_FAMILY.into()
}
pub fn mono_font_family() -> SharedString {
UI_MONO_FONT_FAMILY.into()
}