Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Switch to the system UI font on macOS (#10317)

Nathan Sobo414058379b10
diff --git a/assets/settings/default.json b/assets/settings/default.json
index 19c1357f227..879fdce6d06 100644
--- a/assets/settings/default.json
+++ b/assets/settings/default.json
@@ -36,7 +36,7 @@
// },
"buffer_line_height": "comfortable",
// The name of a font to use for rendering text in the UI
- "ui_font_family": "Zed Sans",
+ "ui_font_family": ".SystemUIFont",
// The OpenType features to enable for text in the UI
"ui_font_features": {
// Disable ligatures:
diff --git a/crates/gpui/src/platform/linux/text_system.rs b/crates/gpui/src/platform/linux/text_system.rs
index e1d5648c134..5164ebd9303 100644
--- a/crates/gpui/src/platform/linux/text_system.rs
+++ b/crates/gpui/src/platform/linux/text_system.rs
@@ -210,9 +210,16 @@ impl LinuxTextSystemState {
#[profiling::function]
fn load_family(
&mut self,
- name: &SharedString,
+ name: &str,
_features: FontFeatures,
) -> Result<SmallVec<[FontId; 4]>> {
+ // TODO: Determine the proper system UI font.
+ let name = if name == ".SystemUIFont" {
+ "Zed Sans"
+ } else {
+ name
+ };
+
let mut font_ids = SmallVec::new();
let families = self
.font_system
diff --git a/crates/gpui/src/platform/mac/text_system.rs b/crates/gpui/src/platform/mac/text_system.rs
index d5bb7230127..2892b517da5 100644
--- a/crates/gpui/src/platform/mac/text_system.rs
+++ b/crates/gpui/src/platform/mac/text_system.rs
@@ -219,16 +219,18 @@ impl MacTextSystemState {
Ok(())
}
- fn load_family(
- &mut self,
- name: &SharedString,
- features: FontFeatures,
- ) -> Result<SmallVec<[FontId; 4]>> {
+ fn load_family(&mut self, name: &str, features: FontFeatures) -> Result<SmallVec<[FontId; 4]>> {
+ let name = if name == ".SystemUIFont" {
+ ".AppleSystemUIFont"
+ } else {
+ name
+ };
+
let mut font_ids = SmallVec::new();
let family = self
.memory_source
- .select_family_by_name(name.as_ref())
- .or_else(|_| self.system_source.select_family_by_name(name.as_ref()))?;
+ .select_family_by_name(name)
+ .or_else(|_| self.system_source.select_family_by_name(name))?;
for font in family.fonts() {
let mut font = font.load()?;
diff --git a/crates/gpui/src/platform/windows/text_system.rs b/crates/gpui/src/platform/windows/text_system.rs
index 5db1a0eea49..6ad8c4be540 100644
--- a/crates/gpui/src/platform/windows/text_system.rs
+++ b/crates/gpui/src/platform/windows/text_system.rs
@@ -209,9 +209,16 @@ impl WindowsTextSystemState {
#[profiling::function]
fn load_family(
&mut self,
- name: &SharedString,
+ name: &str,
_features: FontFeatures,
) -> Result<SmallVec<[FontId; 4]>> {
+ // TODO: Determine the proper system UI font.
+ let name = if name == ".SystemUIFont" {
+ "Zed Sans"
+ } else {
+ name
+ };
+
let mut font_ids = SmallVec::new();
let families = self
.font_system
diff --git a/crates/gpui/src/text_system.rs b/crates/gpui/src/text_system.rs
index f0c8cfafe34..4d044a2837c 100644
--- a/crates/gpui/src/text_system.rs
+++ b/crates/gpui/src/text_system.rs
@@ -675,6 +675,8 @@ impl Hash for RenderEmojiParams {
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct Font {
/// The font family name.
+ ///
+ /// The special name ".SystemUIFont" is used to identify the system UI font, which varies based on platform.
pub family: SharedString,
/// The font features to use.