Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(desktop-gpui): render the interface in the platform system font

Richie McIlroy7925e19e13d5
diff --git a/apps/desktop-gpui/src/camera_window.rs b/apps/desktop-gpui/src/camera_window.rs
index 060ecf0c5..3a7f5497e 100644
--- a/apps/desktop-gpui/src/camera_window.rs
+++ b/apps/desktop-gpui/src/camera_window.rs
@@ -2462,7 +2462,7 @@ impl Render for CameraWindow {
.size_full()
.flex()
.flex_col()
- .font_family("Geist")
+ .font_family(crate::theme::UI_FONT)
// `body { font-weight: 500 }` (`ui-solid/src/main.css:189-192`).
.font_weight(FontWeight::MEDIUM)
// One hover region for the whole window -- bubble, toolbar and
diff --git a/apps/desktop-gpui/src/controls_window.rs b/apps/desktop-gpui/src/controls_window.rs
index f5b0adcaf..acb02cbc8 100644
--- a/apps/desktop-gpui/src/controls_window.rs
+++ b/apps/desktop-gpui/src/controls_window.rs
@@ -489,7 +489,7 @@ impl Render for ControlsWindow {
.flex_col()
.justify_end()
.p(px(12.))
- .font_family("Geist")
+ .font_family(crate::theme::UI_FONT)
// `body { font-weight: 500 }` (`ui-solid/src/main.css:189-192`).
.font_weight(FontWeight::MEDIUM)
.when_some(issue, |this, issue| {
diff --git a/apps/desktop-gpui/src/editor_window.rs b/apps/desktop-gpui/src/editor_window.rs
index 955bab7a3..5270dcd1f 100644
--- a/apps/desktop-gpui/src/editor_window.rs
+++ b/apps/desktop-gpui/src/editor_window.rs
@@ -11187,7 +11187,7 @@ impl Render for EditorWindow {
.size_full()
.flex()
.flex_col()
- .font_family("Geist")
+ .font_family(crate::theme::UI_FONT)
.bg(self.root_bg())
.text_color(Hsla::from(theme.gray_12))
.track_focus(&self.focus)
@@ -11214,7 +11214,7 @@ impl Render for EditorWindow {
.size_full()
.flex()
.flex_col()
- .font_family("Geist")
+ .font_family(crate::theme::UI_FONT)
.bg(self.root_bg())
.text_color(Hsla::from(theme.gray_12))
.track_focus(&self.focus)
diff --git a/apps/desktop-gpui/src/main_window.rs b/apps/desktop-gpui/src/main_window.rs
index 938ba9372..b583e95ec 100644
--- a/apps/desktop-gpui/src/main_window.rs
+++ b/apps/desktop-gpui/src/main_window.rs
@@ -2508,9 +2508,8 @@ impl Render for MainWindow {
.when_some(theme.shell_border(), |this, color| {
this.border_1().border_color(color)
})
- .font_family("Geist")
- // `body { font-family: "Geist Sans"; font-weight: 500 }`
- // (`ui-solid/src/main.css:189-192`). The shipping app renders
+ .font_family(crate::theme::UI_FONT)
+ // `body { font-weight: 500 }` (`ui-solid/src/main.css:189-192`). The shipping app renders
// *everything* Medium unless a `font-*` class says otherwise, so
// Medium -- not Regular -- is the inherited default at every root.
.font_weight(FontWeight::MEDIUM)
diff --git a/apps/desktop-gpui/src/mode_select_window.rs b/apps/desktop-gpui/src/mode_select_window.rs
index b9e7402b3..660d27316 100644
--- a/apps/desktop-gpui/src/mode_select_window.rs
+++ b/apps/desktop-gpui/src/mode_select_window.rs
@@ -249,7 +249,7 @@ impl Render for ModeSelectWindow {
.justify_center()
.items_center()
.bg(Hsla::from(theme.gray_1))
- .font_family("Geist")
+ .font_family(crate::theme::UI_FONT)
// `body { font-weight: 500 }` (`ui-solid/src/main.css:189-192`).
.font_weight(FontWeight::MEDIUM)
.text_color(theme.text_primary)
diff --git a/apps/desktop-gpui/src/onboarding_window.rs b/apps/desktop-gpui/src/onboarding_window.rs
index 1405af3bb..d673229c5 100644
--- a/apps/desktop-gpui/src/onboarding_window.rs
+++ b/apps/desktop-gpui/src/onboarding_window.rs
@@ -2562,7 +2562,7 @@ impl Render for OnboardingWindow {
.overflow_hidden()
.rounded(px(16.))
.bg(theme.shell_bg())
- .font_family("Geist")
+ .font_family(crate::theme::UI_FONT)
.font_weight(FontWeight::MEDIUM)
.text_color(theme.body_text())
.child(header)
diff --git a/apps/desktop-gpui/src/screenshot_editor.rs b/apps/desktop-gpui/src/screenshot_editor.rs
index 3fcacd3c9..1cf2c6566 100644
--- a/apps/desktop-gpui/src/screenshot_editor.rs
+++ b/apps/desktop-gpui/src/screenshot_editor.rs
@@ -4421,7 +4421,7 @@ impl Render for ScreenshotEditorWindow {
.size_full()
.flex()
.flex_col()
- .font_family("Geist")
+ .font_family(crate::theme::UI_FONT)
.font_weight(FontWeight::MEDIUM)
.bg(if theme.is_dark() {
theme.gray_1
diff --git a/apps/desktop-gpui/src/settings_window.rs b/apps/desktop-gpui/src/settings_window.rs
index 33812410c..a1a7fb1fe 100644
--- a/apps/desktop-gpui/src/settings_window.rs
+++ b/apps/desktop-gpui/src/settings_window.rs
@@ -1572,9 +1572,8 @@ impl Render for SettingsWindow {
.rounded(px(theme
.settings_window_radius()
.min(SETTINGS_MATERIAL_RADIUS as f32)))
- .font_family("Geist")
- // `body { font-weight: 500 }` (`ui-solid/src/main.css:189-192`).
- .font_weight(FontWeight::MEDIUM)
+ .font_family(crate::theme::UI_FONT)
+ .font_weight(FontWeight::NORMAL)
.text_color(theme.settings_text());
#[cfg(target_os = "windows")]
diff --git a/apps/desktop-gpui/src/target_overlay.rs b/apps/desktop-gpui/src/target_overlay.rs
index 86361ef65..feb0e2a44 100644
--- a/apps/desktop-gpui/src/target_overlay.rs
+++ b/apps/desktop-gpui/src/target_overlay.rs
@@ -923,7 +923,7 @@ impl Render for OverlayWindow {
)
.size_full()
.relative()
- .font_family("Geist")
+ .font_family(crate::theme::UI_FONT)
// `body { font-weight: 500 }` (`ui-solid/src/main.css:189-192`).
.font_weight(FontWeight::MEDIUM)
.text_color(gpui::white());
diff --git a/apps/desktop-gpui/src/teleprompter_window.rs b/apps/desktop-gpui/src/teleprompter_window.rs
index cd5acac6b..3ba935c27 100644
--- a/apps/desktop-gpui/src/teleprompter_window.rs
+++ b/apps/desktop-gpui/src/teleprompter_window.rs
@@ -583,7 +583,7 @@ impl Render for TeleprompterWindow {
.when_some(theme.teleprompter_shell_border(), |this, color| {
this.border_1().border_color(color)
})
- .font_family("Geist")
+ .font_family(crate::theme::UI_FONT)
// `body { font-weight: 500 }` (`ui-solid/src/main.css:189-192`).
.font_weight(FontWeight::MEDIUM)
.text_color(Hsla::from(theme.gray_12))
diff --git a/apps/desktop-gpui/src/theme.rs b/apps/desktop-gpui/src/theme.rs
index 7f1a1ad4a..371080b33 100644
--- a/apps/desktop-gpui/src/theme.rs
+++ b/apps/desktop-gpui/src/theme.rs
@@ -13,6 +13,15 @@ use gpui::{
use crate::platform::{self, ForcedAppearance, MaterialKind};
use crate::store::AppTheme;
+/// The interface face: the platform's own UI font (SF Pro on macOS, Segoe UI
+/// on Windows) so text matches the system. Linux distros have no reliable
+/// equivalent, so they keep the bundled Geist.
+pub const UI_FONT: &str = if cfg!(any(target_os = "macos", target_os = "windows")) {
+ ".SystemUIFont"
+} else {
+ "Geist"
+};
+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Appearance {
Light,