Allow users to set UI font properties in their settings

Co-Authored-By: Marshall Bowers <1486634+maxdeviant@users.noreply.github.com>
This commit is contained in:
Nate Butler 2023-11-16 11:37:46 -05:00
parent 2aa7c6f2b4
commit c71e522b4e
3 changed files with 24 additions and 4 deletions

View file

@ -35,6 +35,15 @@
// "custom": 2
// },
"buffer_line_height": "comfortable",
// The name of a font to use for rendering text in the UI
"ui_font_family": "Zed Mono",
// The OpenType features to enable for text in the UI
"ui_font_features": {
// Disable ligatures:
"calt": false
},
// The default font size for text in the UI
"ui_font_size": 14,
// The factor to grow the active pane by. Defaults to 1.0
// which gives the same size as all other panes.
"active_pane_magnification": 1.0,

View file

@ -9387,7 +9387,7 @@ impl Render for Editor {
font_size: rems(0.875).into(),
font_weight: FontWeight::NORMAL,
font_style: FontStyle::Normal,
line_height: relative(1.3).into(), // TODO relative(settings.buffer_line_height.value()),
line_height: relative(1.).into(),
underline: None,
}
}

View file

@ -34,6 +34,10 @@ pub struct ThemeSettingsContent {
#[serde(default)]
pub ui_font_size: Option<f32>,
#[serde(default)]
pub ui_font_family: Option<String>,
#[serde(default)]
pub ui_font_features: Option<FontFeatures>,
#[serde(default)]
pub buffer_font_family: Option<String>,
#[serde(default)]
pub buffer_font_size: Option<f32>,
@ -120,10 +124,10 @@ impl settings::Settings for ThemeSettings {
let themes = cx.default_global::<Arc<ThemeRegistry>>();
let mut this = Self {
ui_font_size: defaults.ui_font_size.unwrap_or(16.).into(),
ui_font_size: defaults.ui_font_size.unwrap().into(),
ui_font: Font {
family: "Helvetica".into(),
features: Default::default(),
family: defaults.ui_font_family.clone().unwrap().into(),
features: defaults.ui_font_features.clone().unwrap(),
weight: Default::default(),
style: Default::default(),
},
@ -149,6 +153,13 @@ impl settings::Settings for ThemeSettings {
this.buffer_font.features = value;
}
if let Some(value) = value.ui_font_family {
this.ui_font.family = value.into();
}
if let Some(value) = value.ui_font_features {
this.ui_font.features = value;
}
if let Some(value) = &value.theme {
if let Some(theme) = themes.get(value).log_err() {
this.active_theme = theme;