From 83f9f9d9e3f5914392cab9a09e3472711a1d7b38 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Thu, 16 Oct 2025 07:33:26 +0800 Subject: [PATCH] gpui: Add more default font fallbacks (#35086) Release Notes: - N/A --- - Set `.SystemUIFont` as the GPUI default font. - Add `Arial` to font fallback list. - Add `Adwaita Sans` to default fallback list for Gnome. - Move `Ubuntu` font to front of Gnome to make sure Ubuntu System takes priority over `Ubuntu` font. Our application get some crash report: ``` panicked at /Users/admin/.cargo/git/checkouts/zed-a70e2ad075855582/f1db3b4/crates/gpui/src/text_system.rs:150:9: failed to resolve font 'Helvetica' or any of the fallbacks: Zed Plex Mono, Helvetica, Segoe UI, Cantarell, Ubuntu, Noto Sans, DejaVu Sans ``` This change to add `Arial` to fallback list, this font was included in macOS and Windows. Ref link (search "Arial"): > Mac OS X (now known as [macOS](https://en.wikipedia.org/wiki/MacOS)) was the first Mac OS version to include Arial; > https://en.wikipedia.org/wiki/Arial - macOS Sequoia: https://support.apple.com/en-us/120414 - Windows 10: https://learn.microsoft.com/en-us/typography/fonts/windows_10_font_list - Gnome: https://developer.gnome.org/hig/guidelines/typography.html --- crates/gpui/examples/data_table.rs | 1 - crates/gpui/examples/gradient.rs | 1 - crates/gpui/examples/image_gallery.rs | 2 -- crates/gpui/examples/painting.rs | 1 - crates/gpui/src/style.rs | 8 +------- crates/gpui/src/text_system.rs | 12 +++++++----- 6 files changed, 8 insertions(+), 17 deletions(-) diff --git a/crates/gpui/examples/data_table.rs b/crates/gpui/examples/data_table.rs index e176c44d530ecbc6d5d3140f5c2defaa30a6149e..56c9625ed3039b872cf4fcc70e84719ce903e268 100644 --- a/crates/gpui/examples/data_table.rs +++ b/crates/gpui/examples/data_table.rs @@ -374,7 +374,6 @@ impl DataTable { impl Render for DataTable { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { div() - .font_family(".SystemUIFont") .bg(gpui::white()) .text_sm() .size_full() diff --git a/crates/gpui/examples/gradient.rs b/crates/gpui/examples/gradient.rs index 4a84d2319d1d0b3d432d35dd2b66e168d733cffd..30fb3090a30d4f6c70e968d637dbf98b73559529 100644 --- a/crates/gpui/examples/gradient.rs +++ b/crates/gpui/examples/gradient.rs @@ -20,7 +20,6 @@ impl Render for GradientViewer { let color_space = self.color_space; div() - .font_family(".SystemUIFont") .bg(gpui::white()) .size_full() .p_4() diff --git a/crates/gpui/examples/image_gallery.rs b/crates/gpui/examples/image_gallery.rs index e7abb196c75ef2cd4a9376b10c253e54a89374e5..1fa7a8678f4794b50d245a02e210ea0c2d423ca3 100644 --- a/crates/gpui/examples/image_gallery.rs +++ b/crates/gpui/examples/image_gallery.rs @@ -47,7 +47,6 @@ impl Render for ImageGallery { div() .image_cache(self.image_cache.clone()) .id("main") - .font_family(".SystemUIFont") .text_color(gpui::black()) .bg(rgb(0xE9E9E9)) .overflow_y_scroll() @@ -102,7 +101,6 @@ impl Render for ImageGallery { .child(image_cache(simple_lru_cache("lru-cache", IMAGES_IN_GALLERY)).child( div() .id("main") - .font_family(".SystemUIFont") .bg(rgb(0xE9E9E9)) .text_color(gpui::black()) .overflow_y_scroll() diff --git a/crates/gpui/examples/painting.rs b/crates/gpui/examples/painting.rs index 668aed23772d32a84a81cc0648d6b60dd05e21cf..e7055cbdbbd781523edbc851d143bf56a551728f 100644 --- a/crates/gpui/examples/painting.rs +++ b/crates/gpui/examples/painting.rs @@ -328,7 +328,6 @@ impl Render for PaintingViewer { let dashed = self.dashed; div() - .font_family(".SystemUIFont") .bg(gpui::white()) .size_full() .p_4() diff --git a/crates/gpui/src/style.rs b/crates/gpui/src/style.rs index 8afb4e4eb8af70a78c1cd4fc0176a7fe3baf3c3e..42f8f25e47620fe673720055037b7f91f44165a2 100644 --- a/crates/gpui/src/style.rs +++ b/crates/gpui/src/style.rs @@ -403,13 +403,7 @@ impl Default for TextStyle { TextStyle { color: black(), // todo(linux) make this configurable or choose better default - font_family: if cfg!(any(target_os = "linux", target_os = "freebsd")) { - "FreeMono".into() - } else if cfg!(target_os = "windows") { - "Segoe UI".into() - } else { - "Helvetica".into() - }, + font_family: ".SystemUIFont".into(), font_features: FontFeatures::default(), font_fallbacks: None, font_size: rems(1.).into(), diff --git a/crates/gpui/src/text_system.rs b/crates/gpui/src/text_system.rs index 3de6e639b585bbe52e8d215065dceed6308781e3..cd665aae1b475dda8501ca459492fbf68e71c17f 100644 --- a/crates/gpui/src/text_system.rs +++ b/crates/gpui/src/text_system.rs @@ -75,11 +75,13 @@ impl TextSystem { font(".ZedMono"), font(".ZedSans"), font("Helvetica"), - font("Segoe UI"), // Windows - font("Cantarell"), // Gnome - font("Ubuntu"), // Gnome (Ubuntu) - font("Noto Sans"), // KDE - font("DejaVu Sans") + font("Segoe UI"), // Windows + font("Ubuntu"), // Gnome (Ubuntu) + font("Adwaita Sans"), // Gnome 47 + font("Cantarell"), // Gnome + font("Noto Sans"), // KDE + font("DejaVu Sans"), + font("Arial"), // macOS, Windows ], } }