From 90df5811277d9357febf9522cb8a759176df2776 Mon Sep 17 00:00:00 2001 From: kuddev Date: Sun, 13 Sep 2026 20:34:59 +0800 Subject: [PATCH] refactor(settings): share platform detection for default UI fonts --- nebula_app/src/gpui_shell/theme.rs | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/nebula_app/src/gpui_shell/theme.rs b/nebula_app/src/gpui_shell/theme.rs index 20f5baa..0829216 100644 --- a/nebula_app/src/gpui_shell/theme.rs +++ b/nebula_app/src/gpui_shell/theme.rs @@ -678,21 +678,17 @@ fn apply_skin_tokens(chrome: NebulaTheme, cx: &mut App) { // 我们是终端,所以等宽在这里是**语义标记**而不是全局字体:路径、键帽、 // 命令、数值这类"机器读、要逐字符对齐、要能整段复制"的东西显式走 mono; // 标题和说明是给人读的,走 sans。 - #[cfg(target_os = "windows")] - { - theme.font_family = "Microsoft YaHei UI".into(); - // UI 中的等宽语义也必须稳定。终端字体由 TerminalView 单独读取; - // 若把用户字体组写进全局 theme,tab、标题和代码字面量的字宽都会 - // 随终端主字体变化,进而破坏 chrome 的既定间距。 - theme.mono_font_family = crate::font_install::REQUIRED_FONT_FAMILY.into(); - } - theme.font_family = runtime - .ui_font_family - .unwrap_or_else(|| { - if cfg!(target_os = "windows") { "Microsoft YaHei UI" } else { ".SystemUIFont" } - .to_owned() - }) - .into(); + let default_ui_font = + if crate::platform::Platform::current() == crate::platform::Platform::Windows { + // UI 中的等宽语义也必须稳定。终端字体由 TerminalView 单独读取; + // 若把用户字体组写进全局 theme,tab、标题和代码字面量的字宽都会 + // 随终端主字体变化,进而破坏 chrome 的既定间距。 + theme.mono_font_family = crate::font_install::REQUIRED_FONT_FAMILY.into(); + "Microsoft YaHei UI" + } else { + ".SystemUIFont" + }; + theme.font_family = runtime.ui_font_family.unwrap_or_else(|| default_ui_font.to_owned()).into(); theme.radius = px(crate::display::UI_CORNER_RADIUS_LOGICAL); theme.radius_lg = px(12.0);