refactor(settings): share platform detection for default UI fonts

This commit is contained in:
kuddev committed 2026-09-13 20:34:59 +08:00
1 parent 7d48b6a4fd
commit 90df581127
1 file changed
+11 -15
+11 -15
View File
@@ -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);