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

To reference the system font, use the special ".SystemUIFont" family
name.

/cc @PixelJanitor 

Release Notes:

- Switched to the system UI  font for user interface elements on macOS.

Co-authored-by: Antonio Scandurra <antonio@zed.dev>
This commit is contained in:
Nathan Sobo 2024-04-09 06:44:57 -07:00 committed by GitHub
parent 8205c52d2b
commit 414058379b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 28 additions and 10 deletions

View file

@ -36,7 +36,7 @@
// }, // },
"buffer_line_height": "comfortable", "buffer_line_height": "comfortable",
// The name of a font to use for rendering text in the UI // 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 // The OpenType features to enable for text in the UI
"ui_font_features": { "ui_font_features": {
// Disable ligatures: // Disable ligatures:

View file

@ -210,9 +210,16 @@ impl LinuxTextSystemState {
#[profiling::function] #[profiling::function]
fn load_family( fn load_family(
&mut self, &mut self,
name: &SharedString, name: &str,
_features: FontFeatures, _features: FontFeatures,
) -> Result<SmallVec<[FontId; 4]>> { ) -> 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 mut font_ids = SmallVec::new();
let families = self let families = self
.font_system .font_system

View file

@ -219,16 +219,18 @@ impl MacTextSystemState {
Ok(()) Ok(())
} }
fn load_family( fn load_family(&mut self, name: &str, features: FontFeatures) -> Result<SmallVec<[FontId; 4]>> {
&mut self, let name = if name == ".SystemUIFont" {
name: &SharedString, ".AppleSystemUIFont"
features: FontFeatures, } else {
) -> Result<SmallVec<[FontId; 4]>> { name
};
let mut font_ids = SmallVec::new(); let mut font_ids = SmallVec::new();
let family = self let family = self
.memory_source .memory_source
.select_family_by_name(name.as_ref()) .select_family_by_name(name)
.or_else(|_| self.system_source.select_family_by_name(name.as_ref()))?; .or_else(|_| self.system_source.select_family_by_name(name))?;
for font in family.fonts() { for font in family.fonts() {
let mut font = font.load()?; let mut font = font.load()?;

View file

@ -209,9 +209,16 @@ impl WindowsTextSystemState {
#[profiling::function] #[profiling::function]
fn load_family( fn load_family(
&mut self, &mut self,
name: &SharedString, name: &str,
_features: FontFeatures, _features: FontFeatures,
) -> Result<SmallVec<[FontId; 4]>> { ) -> 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 mut font_ids = SmallVec::new();
let families = self let families = self
.font_system .font_system

View file

@ -675,6 +675,8 @@ impl Hash for RenderEmojiParams {
#[derive(Clone, Debug, Eq, PartialEq, Hash)] #[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct Font { pub struct Font {
/// The font family name. /// The font family name.
///
/// The special name ".SystemUIFont" is used to identify the system UI font, which varies based on platform.
pub family: SharedString, pub family: SharedString,
/// The font features to use. /// The font features to use.