From f8144b3af4afa4a818bc5d3193f8fb29a759b30f Mon Sep 17 00:00:00 2001 From: kuddev Date: Tue, 15 Sep 2026 23:21:20 +0800 Subject: [PATCH] fix(fonts): restore the 1.7 default Maple face Restore Maple Mono Normal NF CN and its original bundled TTF as the default for terminal font selection and fallback. Keep the other Maple family registered for explicit selections and align both configuration template examples. Add a regression checking the default family, filename and exact v1.7 font asset SHA256. This restores the previous default after the visual regression reported in #148; screenshot conditions do not establish a renderer defect. --- .../src/config/templates/pebrel.en-US.lua | 2 +- .../src/config/templates/pebrel.zh-CN.lua | 2 +- nebula_app/src/font_install.rs | 19 ++++++++++++++++--- nebula_app/src/gpui_shell/mod.rs | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/nebula_app/src/config/templates/pebrel.en-US.lua b/nebula_app/src/config/templates/pebrel.en-US.lua index 194b228..31fa112 100644 --- a/nebula_app/src/config/templates/pebrel.en-US.lua +++ b/nebula_app/src/config/templates/pebrel.en-US.lua @@ -11,7 +11,7 @@ config.scrolling = { -- Font example. Remove the leading `--` from each line below to enable it. -- config.font = { --- normal = { family = 'Maple Mono NF CN', style = 'Regular' }, +-- normal = { family = 'Maple Mono Normal NF CN', style = 'Regular' }, -- size = 13.0, -- builtin_box_drawing = true, -- } diff --git a/nebula_app/src/config/templates/pebrel.zh-CN.lua b/nebula_app/src/config/templates/pebrel.zh-CN.lua index c60463b..b2dcc71 100644 --- a/nebula_app/src/config/templates/pebrel.zh-CN.lua +++ b/nebula_app/src/config/templates/pebrel.zh-CN.lua @@ -11,7 +11,7 @@ config.scrolling = { -- 字体示例。取消下面各行开头的 `--` 即可启用。 -- config.font = { --- normal = { family = 'Maple Mono NF CN', style = 'Regular' }, +-- normal = { family = 'Maple Mono Normal NF CN', style = 'Regular' }, -- size = 13.0, -- builtin_box_drawing = true, -- } diff --git a/nebula_app/src/font_install.rs b/nebula_app/src/font_install.rs index 972703a..5f06af6 100644 --- a/nebula_app/src/font_install.rs +++ b/nebula_app/src/font_install.rs @@ -2,13 +2,13 @@ use std::path::{Path, PathBuf}; use sha2::{Digest, Sha256}; -pub const REQUIRED_FONT_FAMILY: &str = "Maple Mono NF CN"; +pub const REQUIRED_FONT_FAMILY: &str = "Maple Mono Normal NF CN"; /// The bundled face is shared by the legacy rasterizer and the GPUI text /// system. Keeping one static byte slice avoids letting the two shells drift /// to different font revisions. pub static REQUIRED_FONT_BYTES: &[u8] = - include_bytes!("../../assets/fonts/MapleMono-NF-CN-Regular.ttf"); + include_bytes!("../../assets/fonts/MapleMonoNormal-NF-CN-Regular.ttf"); /// 一个系统已安装字体族,连同平台给出的等宽判定。 /// @@ -214,7 +214,7 @@ pub fn gpui_font_with_fallbacks(value: &str) -> gpui::Font { } font } -pub const REQUIRED_FONT_FILE: &str = "MapleMono-NF-CN-Regular.ttf"; +pub const REQUIRED_FONT_FILE: &str = "MapleMonoNormal-NF-CN-Regular.ttf"; /// 枚举系统已安装字体族,带 DirectWrite 的权威等宽判定(`IsMonospacedFont`)。 /// @@ -383,6 +383,19 @@ pub fn ensure_bundled_font_on_disk() -> PathBuf { mod tests { use super::*; + #[test] + fn default_face_matches_the_1_7_regular_font_asset() { + assert_eq!(REQUIRED_FONT_FAMILY, "Maple Mono Normal NF CN"); + assert_eq!(REQUIRED_FONT_FILE, "MapleMonoNormal-NF-CN-Regular.ttf"); + assert_eq!( + Sha256::digest(REQUIRED_FONT_BYTES) + .iter() + .map(|byte| format!("{byte:02x}")) + .collect::(), + "9ae0c348a44a681fa8fa20a34e782e95316cec880102295a128b65760944c0f5" + ); + } + fn sys(name: &str, monospaced: bool) -> SystemFontFamily { SystemFontFamily { name: name.to_owned(), monospaced } } diff --git a/nebula_app/src/gpui_shell/mod.rs b/nebula_app/src/gpui_shell/mod.rs index 5bef0d3..e89ef82 100644 --- a/nebula_app/src/gpui_shell/mod.rs +++ b/nebula_app/src/gpui_shell/mod.rs @@ -217,7 +217,7 @@ fn register_bundled_fonts(cx: &App) { // resolve a font so the default remains the same private face as winit. if let Err(error) = cx.text_system().add_fonts(vec![ Cow::Borrowed(crate::font_install::REQUIRED_FONT_BYTES), - Cow::Borrowed(include_bytes!("../../../assets/fonts/MapleMonoNormal-NF-CN-Regular.ttf")), + Cow::Borrowed(include_bytes!("../../../assets/fonts/MapleMono-NF-CN-Regular.ttf")), ]) { try_write_stderr(format_args!( "[nebula:gpui] failed to register bundled Maple font: {error}"