Allow UI font weight to be assigned in settings (#12333)

Release Notes:

- Added the ability to configure the weight of your UI font in standard
CSS weight units from 0 to 900.
This commit is contained in:
Nathan Sobo 2024-05-26 23:06:58 -06:00 committed by GitHub
parent 6276281e8a
commit e19339bc1d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 67 additions and 52 deletions

View file

@ -227,12 +227,18 @@ pub struct ThemeSettingsContent {
/// The OpenType features to enable for text in the UI.
#[serde(default)]
pub ui_font_features: Option<FontFeatures>,
/// The weight of the UI font in CSS units from 100 to 900.
#[serde(default)]
pub ui_font_weight: Option<f32>,
/// The name of a font to use for rendering in text buffers.
#[serde(default)]
pub buffer_font_family: Option<String>,
/// The default font size for rendering in text buffers.
#[serde(default)]
pub buffer_font_size: Option<f32>,
/// The weight of the editor font in CSS units from 100 to 900.
#[serde(default)]
pub buffer_font_weight: Option<f32>,
/// The buffer's line height.
#[serde(default)]
pub buffer_line_height: Option<BufferLineHeight>,
@ -386,13 +392,13 @@ impl settings::Settings for ThemeSettings {
ui_font: Font {
family: defaults.ui_font_family.clone().unwrap().into(),
features: defaults.ui_font_features.clone().unwrap(),
weight: Default::default(),
weight: defaults.ui_font_weight.map(FontWeight).unwrap(),
style: Default::default(),
},
buffer_font: Font {
family: defaults.buffer_font_family.clone().unwrap().into(),
features: defaults.buffer_font_features.clone().unwrap(),
weight: FontWeight::default(),
weight: defaults.buffer_font_weight.map(FontWeight).unwrap(),
style: FontStyle::default(),
},
buffer_font_size: defaults.buffer_font_size.unwrap().into(),
@ -418,12 +424,19 @@ impl settings::Settings for ThemeSettings {
this.buffer_font.features = value;
}
if let Some(value) = value.buffer_font_weight {
this.buffer_font.weight = FontWeight(value);
}
if let Some(value) = value.ui_font_family.clone() {
this.ui_font.family = value.into();
}
if let Some(value) = value.ui_font_features.clone() {
this.ui_font.features = value;
}
if let Some(value) = value.ui_font_weight {
this.ui_font.weight = FontWeight(value);
}
if let Some(value) = &value.theme {
this.theme_selection = Some(value.clone());