From 4bad75e52212cc99bf5751a9c10a4e162a867023 Mon Sep 17 00:00:00 2001 From: TomZz Date: Fri, 12 Jun 2026 01:03:47 +0800 Subject: [PATCH] UI: Optimize font selection layout and prioritize built-in font MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Align UI font and Terminal font label widths (180px -> 240px) to match other settings - Pin 'Maple Mono NF CN' to the top of font dropdown menus - Add localized '(Built-in)' / '(软件内置)' suffix to the built-in font - Add a visual separator below the built-in font in the dropdown menu - Add 'software_builtin' translation keys in en.yml and zh-CN.yml --- locales/en.yml | 2 ++ locales/zh-CN.yml | 2 ++ src/main.rs | 45 ++++++++++++++++++++++++++++++++++++++------- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/locales/en.yml b/locales/en.yml index bcbf0db..026d776 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -90,3 +90,5 @@ completed: "Completed" failed: "Failed" cancelled: "Cancelled" session: "Session" + +software_builtin: "Built-in" \ No newline at end of file diff --git a/locales/zh-CN.yml b/locales/zh-CN.yml index 2d2e30b..a7f1e48 100644 --- a/locales/zh-CN.yml +++ b/locales/zh-CN.yml @@ -90,3 +90,5 @@ completed: "已完成" failed: "失败" cancelled: "已取消" session: "会话" + +software_builtin: "软件内置" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 7c396f1..6a6395f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1434,7 +1434,7 @@ impl Ashell { .gap_3() .child( div() - .w(px(180.)) + .w(px(240.)) .child(t!("ui_font_family").to_string()), ) .child( @@ -1452,6 +1452,8 @@ impl Ashell { || !names.contains(¤t) { t!("system_default").to_string() + } else if current == "Maple Mono NF CN" { + format!("Maple Mono NF CN ({})", t!("software_builtin")) } else { current } @@ -1465,7 +1467,7 @@ impl Ashell { .read(cx) .ui_font_family .to_string(); - let names = + let mut names = cx.text_system().all_font_names(); menu = menu.min_w(200.).max_h( px(320.), @@ -1496,6 +1498,19 @@ impl Ashell { }, )), ); + + let maple_font = "Maple Mono NF CN".to_string(); + if names.contains(&maple_font) { + names.retain(|n| n != &maple_font); + menu = menu.item( + PopupMenuItem::new(format!("{} ({})", maple_font, t!("software_builtin"))) + .checked(current == maple_font) + .on_click(window.listener_for(&view, move |this, _, window, cx| { + this.change_ui_font_family("Maple Mono NF CN", window, cx); + })) + ).separator(); + } + for name in names { let checked = name == current; @@ -1531,7 +1546,7 @@ impl Ashell { .gap_3() .child( div() - .w(px(180.)) + .w(px(240.)) .child(t!("terminal_font_family").to_string()), ) .child( @@ -1539,9 +1554,12 @@ impl Ashell { .small() .icon(IconName::ChevronsUpDown) .label({ - view.read(cx) - .terminal_font_family - .to_string() + let current = view.read(cx).terminal_font_family.to_string(); + if current == "Maple Mono NF CN" { + format!("Maple Mono NF CN ({})", t!("software_builtin")) + } else { + current + } }) .dropdown_menu_with_anchor( Anchor::BottomRight, @@ -1552,11 +1570,24 @@ impl Ashell { .read(cx) .terminal_font_family .to_string(); - let names = + let mut names = cx.text_system().all_font_names(); menu = menu.min_w(200.).max_h( px(320.), ).scrollable(true); + + let maple_font = "Maple Mono NF CN".to_string(); + if names.contains(&maple_font) { + names.retain(|n| n != &maple_font); + menu = menu.item( + PopupMenuItem::new(format!("{} ({})", maple_font, t!("software_builtin"))) + .checked(current == maple_font) + .on_click(window.listener_for(&view, move |this, _, _window, cx| { + this.change_terminal_font_family("Maple Mono NF CN", cx); + })) + ).separator(); + } + for name in names { let checked = name == current;