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.
This commit is contained in:
1 parent
12f0ef278f
commit
f8144b3af4
4 files changed
+19
-6
No files matched your search
@@ -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,
|
||||
-- }
|
||||
|
||||
@@ -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,
|
||||
-- }
|
||||
|
||||
@@ -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::<String>(),
|
||||
"9ae0c348a44a681fa8fa20a34e782e95316cec880102295a128b65760944c0f5"
|
||||
);
|
||||
}
|
||||
|
||||
fn sys(name: &str, monospaced: bool) -> SystemFontFamily {
|
||||
SystemFontFamily { name: name.to_owned(), monospaced }
|
||||
}
|
||||
|
||||
@@ -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}"
|
||||
|
||||
Reference in new issue
Block a user