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",
// 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:

View File

@ -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

View File

@ -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()?;

View File

@ -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

View File

@ -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.