From d2c39fd5c2b974da833e516749bda4c03c1309f9 Mon Sep 17 00:00:00 2001 From: Hikari Date: Tue, 3 Mar 2026 18:41:21 -0800 Subject: [PATCH] feat: add custom UI font support Allow users to specify a custom font for the entire app interface (menus, labels, buttons) separately from the terminal font. Supports Google Fonts URLs, direct font file URLs, and local file paths. - Add custom_ui_font_path and custom_ui_font_family to Rust config - Refactor applyCustomFont into shared applyFontFromSource helper - Add applyCustomUiFont function using --ui-font-family CSS variable - Update app.css to use --ui-font-family with fallback - Apply custom UI font on startup in +page.svelte - Add Custom UI Font section to ConfigSidebar settings panel - Add tests for applyCustomUiFont and setCustomUiFont --- src-tauri/src/config.rs | 15 ++- src/app.css | 6 +- src/lib/components/ConfigSidebar.svelte | 70 ++++++++++++ src/lib/components/StatusBar.svelte | 2 + src/lib/stores/config.test.ts | 136 ++++++++++++++++++++++++ src/lib/stores/config.ts | 125 ++++++++++++++-------- src/routes/+page.svelte | 2 + 7 files changed, 306 insertions(+), 50 deletions(-) diff --git a/src-tauri/src/config.rs b/src-tauri/src/config.rs index dae5ac7..cfb4f7f 100644 --- a/src-tauri/src/config.rs +++ b/src-tauri/src/config.rs @@ -145,12 +145,19 @@ pub struct HikariConfig { #[serde(default)] pub show_thinking_blocks: bool, - // Custom font settings + // Custom terminal font settings #[serde(default)] pub custom_font_path: Option, #[serde(default)] pub custom_font_family: Option, + + // Custom UI font settings + #[serde(default)] + pub custom_ui_font_path: Option, + + #[serde(default)] + pub custom_ui_font_family: Option, } impl Default for HikariConfig { @@ -192,6 +199,8 @@ impl Default for HikariConfig { show_thinking_blocks: false, custom_font_path: None, custom_font_family: None, + custom_ui_font_path: None, + custom_ui_font_family: None, } } } @@ -309,6 +318,8 @@ mod tests { assert!(!config.show_thinking_blocks); assert!(config.custom_font_path.is_none()); assert!(config.custom_font_family.is_none()); + assert!(config.custom_ui_font_path.is_none()); + assert!(config.custom_ui_font_family.is_none()); } #[test] @@ -350,6 +361,8 @@ mod tests { show_thinking_blocks: true, custom_font_path: Some("/home/naomi/.fonts/MyFont.ttf".to_string()), custom_font_family: Some("MyFont".to_string()), + custom_ui_font_path: None, + custom_ui_font_family: None, }; let json = serde_json::to_string(&config).unwrap(); diff --git a/src/app.css b/src/app.css index 13b8324..88bf299 100644 --- a/src/app.css +++ b/src/app.css @@ -154,11 +154,7 @@ body { padding: 0; height: 100%; overflow: hidden; - font-family: - "Segoe UI", - system-ui, - -apple-system, - sans-serif; + font-family: var(--ui-font-family, "Segoe UI", system-ui, -apple-system, sans-serif); background: var(--bg-primary); color: var(--text-primary); } diff --git a/src/lib/components/ConfigSidebar.svelte b/src/lib/components/ConfigSidebar.svelte index 8d5ff5e..0047489 100644 --- a/src/lib/components/ConfigSidebar.svelte +++ b/src/lib/components/ConfigSidebar.svelte @@ -6,6 +6,7 @@ type CustomThemeColors, applyFontSize, applyCustomFont, + applyCustomUiFont, applyCustomThemeColors, MIN_FONT_SIZE, MAX_FONT_SIZE, @@ -63,12 +64,17 @@ background_image_opacity: 0.3, custom_font_path: null, custom_font_family: null, + custom_ui_font_path: null, + custom_ui_font_family: null, }); let showCustomThemeEditor = $state(false); let customFontPathInput = $state(""); let customFontFamilyInput = $state(""); let customFontStatus: string | null = $state(null); + let customUiFontPathInput = $state(""); + let customUiFontFamilyInput = $state(""); + let customUiFontStatus: string | null = $state(null); interface AuthStatus { is_logged_in: boolean; @@ -96,6 +102,8 @@ config = { ...c }; customFontPathInput = c.custom_font_path ?? ""; customFontFamilyInput = c.custom_font_family ?? ""; + customUiFontPathInput = c.custom_ui_font_path ?? ""; + customUiFontFamilyInput = c.custom_ui_font_family ?? ""; }); configStore.isSidebarOpen.subscribe((open) => { @@ -1007,6 +1015,68 @@

+ +
+ Custom UI Font +
+ + +
+ + +
+ {#if customUiFontStatus} +

{customUiFontStatus}

+ {/if} +
+

+ Applies to the entire app interface (menus, labels, buttons). Supports Google Fonts URLs, + direct font file URLs, or local file paths. +

+
+