theme.rs

   1use collections::{HashMap, IndexMap};
   2use gpui::{FontFallbacks, FontFeatures, FontStyle, FontWeight, SharedString};
   3use schemars::{JsonSchema, JsonSchema_repr};
   4use serde::{Deserialize, Deserializer, Serialize};
   5use serde_json::Value;
   6use serde_repr::{Deserialize_repr, Serialize_repr};
   7use settings_macros::{MergeFrom, with_fallible_options};
   8use std::{fmt::Display, sync::Arc};
   9
  10use crate::serialize_f32_with_two_decimal_places;
  11
  12/// Settings for rendering text in UI and text buffers.
  13
  14#[with_fallible_options]
  15#[derive(Clone, PartialEq, Debug, Default, Serialize, Deserialize, JsonSchema, MergeFrom)]
  16pub struct ThemeSettingsContent {
  17    /// The default font size for text in the UI.
  18    #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
  19    pub ui_font_size: Option<f32>,
  20    /// The name of a font to use for rendering in the UI.
  21    pub ui_font_family: Option<FontFamilyName>,
  22    /// The font fallbacks to use for rendering in the UI.
  23    #[schemars(default = "default_font_fallbacks")]
  24    #[schemars(extend("uniqueItems" = true))]
  25    pub ui_font_fallbacks: Option<Vec<FontFamilyName>>,
  26    /// The OpenType features to enable for text in the UI.
  27    #[schemars(default = "default_font_features")]
  28    pub ui_font_features: Option<FontFeatures>,
  29    /// The weight of the UI font in CSS units from 100 to 900.
  30    #[schemars(default = "default_buffer_font_weight")]
  31    pub ui_font_weight: Option<FontWeight>,
  32    /// The name of a font to use for rendering in text buffers.
  33    pub buffer_font_family: Option<FontFamilyName>,
  34    /// The font fallbacks to use for rendering in text buffers.
  35    #[schemars(extend("uniqueItems" = true))]
  36    pub buffer_font_fallbacks: Option<Vec<FontFamilyName>>,
  37    /// The default font size for rendering in text buffers.
  38    #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
  39    pub buffer_font_size: Option<f32>,
  40    /// The weight of the editor font in CSS units from 100 to 900.
  41    #[schemars(default = "default_buffer_font_weight")]
  42    pub buffer_font_weight: Option<FontWeight>,
  43    /// The buffer's line height.
  44    pub buffer_line_height: Option<BufferLineHeight>,
  45    /// The OpenType features to enable for rendering in text buffers.
  46    #[schemars(default = "default_font_features")]
  47    pub buffer_font_features: Option<FontFeatures>,
  48    /// The font size for agent responses in the agent panel. Falls back to the UI font size if unset.
  49    #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
  50    pub agent_ui_font_size: Option<f32>,
  51    /// The font size for user messages in the agent panel.
  52    #[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
  53    pub agent_buffer_font_size: Option<f32>,
  54    /// The name of the Zed theme to use.
  55    pub theme: Option<ThemeSelection>,
  56    /// The name of the icon theme to use.
  57    pub icon_theme: Option<IconThemeSelection>,
  58
  59    /// UNSTABLE: Expect many elements to be broken.
  60    ///
  61    // Controls the density of the UI.
  62    #[serde(rename = "unstable.ui_density")]
  63    pub ui_density: Option<UiDensity>,
  64
  65    /// How much to fade out unused code.
  66    #[schemars(range(min = 0.0, max = 0.9))]
  67    pub unnecessary_code_fade: Option<CodeFade>,
  68
  69    /// EXPERIMENTAL: Overrides for the current theme.
  70    ///
  71    /// These values will override the ones on the current theme specified in `theme`.
  72    #[serde(rename = "experimental.theme_overrides")]
  73    pub experimental_theme_overrides: Option<ThemeStyleContent>,
  74
  75    /// Overrides per theme
  76    ///
  77    /// These values will override the ones on the specified theme
  78    #[serde(default)]
  79    pub theme_overrides: HashMap<String, ThemeStyleContent>,
  80}
  81
  82#[derive(
  83    Clone,
  84    Copy,
  85    Debug,
  86    Serialize,
  87    Deserialize,
  88    JsonSchema,
  89    MergeFrom,
  90    PartialEq,
  91    PartialOrd,
  92    derive_more::FromStr,
  93)]
  94#[serde(transparent)]
  95pub struct CodeFade(#[serde(serialize_with = "serialize_f32_with_two_decimal_places")] pub f32);
  96
  97impl Display for CodeFade {
  98    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
  99        write!(f, "{:.2}", self.0)
 100    }
 101}
 102
 103impl From<f32> for CodeFade {
 104    fn from(x: f32) -> Self {
 105        Self(x)
 106    }
 107}
 108
 109fn default_font_features() -> Option<FontFeatures> {
 110    Some(FontFeatures::default())
 111}
 112
 113fn default_font_fallbacks() -> Option<FontFallbacks> {
 114    Some(FontFallbacks::default())
 115}
 116
 117fn default_buffer_font_weight() -> Option<FontWeight> {
 118    Some(FontWeight::default())
 119}
 120
 121/// Represents the selection of a theme, which can be either static or dynamic.
 122#[derive(
 123    Clone,
 124    Debug,
 125    Serialize,
 126    Deserialize,
 127    JsonSchema,
 128    MergeFrom,
 129    PartialEq,
 130    Eq,
 131    strum::EnumDiscriminants,
 132)]
 133#[strum_discriminants(derive(strum::VariantArray, strum::VariantNames, strum::FromRepr))]
 134#[serde(untagged)]
 135pub enum ThemeSelection {
 136    /// A static theme selection, represented by a single theme name.
 137    Static(ThemeName),
 138    /// A dynamic theme selection, which can change based the [ThemeMode].
 139    Dynamic {
 140        /// The mode used to determine which theme to use.
 141        #[serde(default)]
 142        mode: ThemeAppearanceMode,
 143        /// The theme to use for light mode.
 144        light: ThemeName,
 145        /// The theme to use for dark mode.
 146        dark: ThemeName,
 147    },
 148}
 149
 150/// Represents the selection of an icon theme, which can be either static or dynamic.
 151#[derive(
 152    Clone,
 153    Debug,
 154    Serialize,
 155    Deserialize,
 156    JsonSchema,
 157    MergeFrom,
 158    PartialEq,
 159    Eq,
 160    strum::EnumDiscriminants,
 161)]
 162#[strum_discriminants(derive(strum::VariantArray, strum::VariantNames, strum::FromRepr))]
 163#[serde(untagged)]
 164pub enum IconThemeSelection {
 165    /// A static icon theme selection, represented by a single icon theme name.
 166    Static(IconThemeName),
 167    /// A dynamic icon theme selection, which can change based on the [`ThemeMode`].
 168    Dynamic {
 169        /// The mode used to determine which theme to use.
 170        #[serde(default)]
 171        mode: ThemeAppearanceMode,
 172        /// The icon theme to use for light mode.
 173        light: IconThemeName,
 174        /// The icon theme to use for dark mode.
 175        dark: IconThemeName,
 176    },
 177}
 178
 179/// The mode use to select a theme.
 180///
 181/// `Light` and `Dark` will select their respective themes.
 182///
 183/// `System` will select the theme based on the system's appearance.
 184#[derive(
 185    Debug,
 186    PartialEq,
 187    Eq,
 188    Clone,
 189    Copy,
 190    Default,
 191    Serialize,
 192    Deserialize,
 193    JsonSchema,
 194    MergeFrom,
 195    strum::VariantArray,
 196    strum::VariantNames,
 197)]
 198#[serde(rename_all = "snake_case")]
 199pub enum ThemeAppearanceMode {
 200    /// Use the specified `light` theme.
 201    Light,
 202
 203    /// Use the specified `dark` theme.
 204    Dark,
 205
 206    /// Use the theme based on the system's appearance.
 207    #[default]
 208    System,
 209}
 210
 211/// Specifies the density of the UI.
 212/// Note: This setting is still experimental. See [this tracking issue](https://github.com/zed-industries/zed/issues/18078)
 213#[derive(
 214    Debug,
 215    Default,
 216    PartialEq,
 217    Eq,
 218    PartialOrd,
 219    Ord,
 220    Hash,
 221    Clone,
 222    Copy,
 223    Serialize,
 224    Deserialize,
 225    JsonSchema,
 226    MergeFrom,
 227)]
 228#[serde(rename_all = "snake_case")]
 229pub enum UiDensity {
 230    /// A denser UI with tighter spacing and smaller elements.
 231    #[serde(alias = "compact")]
 232    Compact,
 233    #[default]
 234    #[serde(alias = "default")]
 235    /// The default UI density.
 236    Default,
 237    #[serde(alias = "comfortable")]
 238    /// A looser UI with more spacing and larger elements.
 239    Comfortable,
 240}
 241
 242impl UiDensity {
 243    /// The spacing ratio of a given density.
 244    /// TODO: Standardize usage throughout the app or remove
 245    pub fn spacing_ratio(self) -> f32 {
 246        match self {
 247            UiDensity::Compact => 0.75,
 248            UiDensity::Default => 1.0,
 249            UiDensity::Comfortable => 1.25,
 250        }
 251    }
 252}
 253
 254/// Font family name.
 255#[with_fallible_options]
 256#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
 257#[serde(transparent)]
 258pub struct FontFamilyName(pub Arc<str>);
 259
 260impl AsRef<str> for FontFamilyName {
 261    fn as_ref(&self) -> &str {
 262        &self.0
 263    }
 264}
 265
 266impl From<SharedString> for FontFamilyName {
 267    fn from(value: SharedString) -> Self {
 268        Self(Arc::from(value))
 269    }
 270}
 271
 272impl From<FontFamilyName> for SharedString {
 273    fn from(value: FontFamilyName) -> Self {
 274        SharedString::new(value.0)
 275    }
 276}
 277
 278impl From<String> for FontFamilyName {
 279    fn from(value: String) -> Self {
 280        Self(Arc::from(value))
 281    }
 282}
 283
 284impl From<FontFamilyName> for String {
 285    fn from(value: FontFamilyName) -> Self {
 286        value.0.to_string()
 287    }
 288}
 289
 290/// The buffer's line height.
 291#[derive(
 292    Clone,
 293    Copy,
 294    Debug,
 295    Serialize,
 296    Deserialize,
 297    PartialEq,
 298    JsonSchema,
 299    MergeFrom,
 300    Default,
 301    strum::EnumDiscriminants,
 302)]
 303#[strum_discriminants(derive(strum::VariantArray, strum::VariantNames, strum::FromRepr))]
 304#[serde(rename_all = "snake_case")]
 305pub enum BufferLineHeight {
 306    /// A less dense line height.
 307    #[default]
 308    Comfortable,
 309    /// The default line height.
 310    Standard,
 311    /// A custom line height, where 1.0 is the font's height. Must be at least 1.0.
 312    Custom(#[serde(deserialize_with = "deserialize_line_height")] f32),
 313}
 314
 315fn deserialize_line_height<'de, D>(deserializer: D) -> Result<f32, D::Error>
 316where
 317    D: serde::Deserializer<'de>,
 318{
 319    let value = f32::deserialize(deserializer)?;
 320    if value < 1.0 {
 321        return Err(serde::de::Error::custom(
 322            "buffer_line_height.custom must be at least 1.0",
 323        ));
 324    }
 325
 326    Ok(value)
 327}
 328
 329/// The content of a serialized theme.
 330#[with_fallible_options]
 331#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
 332#[serde(default)]
 333pub struct ThemeStyleContent {
 334    #[serde(rename = "background.appearance")]
 335    pub window_background_appearance: Option<WindowBackgroundContent>,
 336
 337    #[serde(default)]
 338    pub accents: Vec<AccentContent>,
 339
 340    #[serde(flatten, default)]
 341    pub colors: ThemeColorsContent,
 342
 343    #[serde(flatten, default)]
 344    pub status: StatusColorsContent,
 345
 346    #[serde(default)]
 347    pub players: Vec<PlayerColorContent>,
 348
 349    /// The styles for syntax nodes.
 350    #[serde(default)]
 351    pub syntax: IndexMap<String, HighlightStyleContent>,
 352}
 353
 354#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
 355pub struct AccentContent(pub Option<SharedString>);
 356
 357#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
 358pub struct PlayerColorContent {
 359    pub cursor: Option<String>,
 360    pub background: Option<String>,
 361    pub selection: Option<String>,
 362}
 363
 364/// Theme name.
 365#[with_fallible_options]
 366#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
 367#[serde(transparent)]
 368pub struct ThemeName(pub Arc<str>);
 369
 370/// Icon Theme Name
 371#[with_fallible_options]
 372#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)]
 373#[serde(transparent)]
 374pub struct IconThemeName(pub Arc<str>);
 375
 376#[with_fallible_options]
 377#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
 378#[serde(default)]
 379pub struct ThemeColorsContent {
 380    /// Border color. Used for most borders, is usually a high contrast color.
 381    #[serde(rename = "border")]
 382    pub border: Option<String>,
 383
 384    /// Border color. Used for deemphasized borders, like a visual divider between two sections
 385    #[serde(rename = "border.variant")]
 386    pub border_variant: Option<String>,
 387
 388    /// Border color. Used for focused elements, like keyboard focused list item.
 389    #[serde(rename = "border.focused")]
 390    pub border_focused: Option<String>,
 391
 392    /// Border color. Used for selected elements, like an active search filter or selected checkbox.
 393    #[serde(rename = "border.selected")]
 394    pub border_selected: Option<String>,
 395
 396    /// Border color. Used for transparent borders. Used for placeholder borders when an element gains a border on state change.
 397    #[serde(rename = "border.transparent")]
 398    pub border_transparent: Option<String>,
 399
 400    /// Border color. Used for disabled elements, like a disabled input or button.
 401    #[serde(rename = "border.disabled")]
 402    pub border_disabled: Option<String>,
 403
 404    /// Background color. Used for elevated surfaces, like a context menu, popup, or dialog.
 405    #[serde(rename = "elevated_surface.background")]
 406    pub elevated_surface_background: Option<String>,
 407
 408    /// Background Color. Used for grounded surfaces like a panel or tab.
 409    #[serde(rename = "surface.background")]
 410    pub surface_background: Option<String>,
 411
 412    /// Background Color. Used for the app background and blank panels or windows.
 413    #[serde(rename = "background")]
 414    pub background: Option<String>,
 415
 416    /// Background Color. Used for the background of an element that should have a different background than the surface it's on.
 417    ///
 418    /// Elements might include: Buttons, Inputs, Checkboxes, Radio Buttons...
 419    ///
 420    /// For an element that should have the same background as the surface it's on, use `ghost_element_background`.
 421    #[serde(rename = "element.background")]
 422    pub element_background: Option<String>,
 423
 424    /// Background Color. Used for the hover state of an element that should have a different background than the surface it's on.
 425    ///
 426    /// Hover states are triggered by the mouse entering an element, or a finger touching an element on a touch screen.
 427    #[serde(rename = "element.hover")]
 428    pub element_hover: Option<String>,
 429
 430    /// Background Color. Used for the active state of an element that should have a different background than the surface it's on.
 431    ///
 432    /// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressed.
 433    #[serde(rename = "element.active")]
 434    pub element_active: Option<String>,
 435
 436    /// Background Color. Used for the selected state of an element that should have a different background than the surface it's on.
 437    ///
 438    /// Selected states are triggered by the element being selected (or "activated") by the user.
 439    ///
 440    /// This could include a selected checkbox, a toggleable button that is toggled on, etc.
 441    #[serde(rename = "element.selected")]
 442    pub element_selected: Option<String>,
 443
 444    /// Background Color. Used for the disabled state of an element that should have a different background than the surface it's on.
 445    ///
 446    /// Disabled states are shown when a user cannot interact with an element, like a disabled button or input.
 447    #[serde(rename = "element.disabled")]
 448    pub element_disabled: Option<String>,
 449
 450    /// Background Color. Used for the background of selections in a UI element.
 451    #[serde(rename = "element.selection_background")]
 452    pub element_selection_background: Option<String>,
 453
 454    /// Background Color. Used for the area that shows where a dragged element will be dropped.
 455    #[serde(rename = "drop_target.background")]
 456    pub drop_target_background: Option<String>,
 457
 458    /// Border Color. Used for the border that shows where a dragged element will be dropped.
 459    #[serde(rename = "drop_target.border")]
 460    pub drop_target_border: Option<String>,
 461
 462    /// Used for the background of a ghost element that should have the same background as the surface it's on.
 463    ///
 464    /// Elements might include: Buttons, Inputs, Checkboxes, Radio Buttons...
 465    ///
 466    /// For an element that should have a different background than the surface it's on, use `element_background`.
 467    #[serde(rename = "ghost_element.background")]
 468    pub ghost_element_background: Option<String>,
 469
 470    /// Background Color. Used for the hover state of a ghost element that should have the same background as the surface it's on.
 471    ///
 472    /// Hover states are triggered by the mouse entering an element, or a finger touching an element on a touch screen.
 473    #[serde(rename = "ghost_element.hover")]
 474    pub ghost_element_hover: Option<String>,
 475
 476    /// Background Color. Used for the active state of a ghost element that should have the same background as the surface it's on.
 477    ///
 478    /// Active states are triggered by the mouse button being pressed down on an element, or the Return button or other activator being pressed.
 479    #[serde(rename = "ghost_element.active")]
 480    pub ghost_element_active: Option<String>,
 481
 482    /// Background Color. Used for the selected state of a ghost element that should have the same background as the surface it's on.
 483    ///
 484    /// Selected states are triggered by the element being selected (or "activated") by the user.
 485    ///
 486    /// This could include a selected checkbox, a toggleable button that is toggled on, etc.
 487    #[serde(rename = "ghost_element.selected")]
 488    pub ghost_element_selected: Option<String>,
 489
 490    /// Background Color. Used for the disabled state of a ghost element that should have the same background as the surface it's on.
 491    ///
 492    /// Disabled states are shown when a user cannot interact with an element, like a disabled button or input.
 493    #[serde(rename = "ghost_element.disabled")]
 494    pub ghost_element_disabled: Option<String>,
 495
 496    /// Text Color. Default text color used for most text.
 497    #[serde(rename = "text")]
 498    pub text: Option<String>,
 499
 500    /// Text Color. Color of muted or deemphasized text. It is a subdued version of the standard text color.
 501    #[serde(rename = "text.muted")]
 502    pub text_muted: Option<String>,
 503
 504    /// Text Color. Color of the placeholder text typically shown in input fields to guide the user to enter valid data.
 505    #[serde(rename = "text.placeholder")]
 506    pub text_placeholder: Option<String>,
 507
 508    /// Text Color. Color used for text denoting disabled elements. Typically, the color is faded or grayed out to emphasize the disabled state.
 509    #[serde(rename = "text.disabled")]
 510    pub text_disabled: Option<String>,
 511
 512    /// Text Color. Color used for emphasis or highlighting certain text, like an active filter or a matched character in a search.
 513    #[serde(rename = "text.accent")]
 514    pub text_accent: Option<String>,
 515
 516    /// Fill Color. Used for the default fill color of an icon.
 517    #[serde(rename = "icon")]
 518    pub icon: Option<String>,
 519
 520    /// Fill Color. Used for the muted or deemphasized fill color of an icon.
 521    ///
 522    /// This might be used to show an icon in an inactive pane, or to deemphasize a series of icons to give them less visual weight.
 523    #[serde(rename = "icon.muted")]
 524    pub icon_muted: Option<String>,
 525
 526    /// Fill Color. Used for the disabled fill color of an icon.
 527    ///
 528    /// Disabled states are shown when a user cannot interact with an element, like a icon button.
 529    #[serde(rename = "icon.disabled")]
 530    pub icon_disabled: Option<String>,
 531
 532    /// Fill Color. Used for the placeholder fill color of an icon.
 533    ///
 534    /// This might be used to show an icon in an input that disappears when the user enters text.
 535    #[serde(rename = "icon.placeholder")]
 536    pub icon_placeholder: Option<String>,
 537
 538    /// Fill Color. Used for the accent fill color of an icon.
 539    ///
 540    /// This might be used to show when a toggleable icon button is selected.
 541    #[serde(rename = "icon.accent")]
 542    pub icon_accent: Option<String>,
 543
 544    /// Color used to accent some of the debuggers elements
 545    /// Only accent breakpoint & breakpoint related symbols right now
 546    #[serde(rename = "debugger.accent")]
 547    pub debugger_accent: Option<String>,
 548
 549    #[serde(rename = "status_bar.background")]
 550    pub status_bar_background: Option<String>,
 551
 552    #[serde(rename = "title_bar.background")]
 553    pub title_bar_background: Option<String>,
 554
 555    #[serde(rename = "title_bar.inactive_background")]
 556    pub title_bar_inactive_background: Option<String>,
 557
 558    #[serde(rename = "toolbar.background")]
 559    pub toolbar_background: Option<String>,
 560
 561    #[serde(rename = "tab_bar.background")]
 562    pub tab_bar_background: Option<String>,
 563
 564    #[serde(rename = "tab.inactive_background")]
 565    pub tab_inactive_background: Option<String>,
 566
 567    #[serde(rename = "tab.active_background")]
 568    pub tab_active_background: Option<String>,
 569
 570    #[serde(rename = "search.match_background")]
 571    pub search_match_background: Option<String>,
 572
 573    #[serde(rename = "search.active_match_background")]
 574    pub search_active_match_background: Option<String>,
 575
 576    #[serde(rename = "panel.background")]
 577    pub panel_background: Option<String>,
 578
 579    #[serde(rename = "panel.focused_border")]
 580    pub panel_focused_border: Option<String>,
 581
 582    #[serde(rename = "panel.indent_guide")]
 583    pub panel_indent_guide: Option<String>,
 584
 585    #[serde(rename = "panel.indent_guide_hover")]
 586    pub panel_indent_guide_hover: Option<String>,
 587
 588    #[serde(rename = "panel.indent_guide_active")]
 589    pub panel_indent_guide_active: Option<String>,
 590
 591    #[serde(rename = "panel.overlay_background")]
 592    pub panel_overlay_background: Option<String>,
 593
 594    #[serde(rename = "panel.overlay_hover")]
 595    pub panel_overlay_hover: Option<String>,
 596
 597    #[serde(rename = "pane.focused_border")]
 598    pub pane_focused_border: Option<String>,
 599
 600    #[serde(rename = "pane_group.border")]
 601    pub pane_group_border: Option<String>,
 602
 603    /// The deprecated version of `scrollbar.thumb.background`.
 604    ///
 605    /// Don't use this field.
 606    #[serde(rename = "scrollbar_thumb.background", skip_serializing)]
 607    #[schemars(skip)]
 608    pub deprecated_scrollbar_thumb_background: Option<String>,
 609
 610    /// The color of the scrollbar thumb.
 611    #[serde(rename = "scrollbar.thumb.background")]
 612    pub scrollbar_thumb_background: Option<String>,
 613
 614    /// The color of the scrollbar thumb when hovered over.
 615    #[serde(rename = "scrollbar.thumb.hover_background")]
 616    pub scrollbar_thumb_hover_background: Option<String>,
 617
 618    /// The color of the scrollbar thumb whilst being actively dragged.
 619    #[serde(rename = "scrollbar.thumb.active_background")]
 620    pub scrollbar_thumb_active_background: Option<String>,
 621
 622    /// The border color of the scrollbar thumb.
 623    #[serde(rename = "scrollbar.thumb.border")]
 624    pub scrollbar_thumb_border: Option<String>,
 625
 626    /// The background color of the scrollbar track.
 627    #[serde(rename = "scrollbar.track.background")]
 628    pub scrollbar_track_background: Option<String>,
 629
 630    /// The border color of the scrollbar track.
 631    #[serde(rename = "scrollbar.track.border")]
 632    pub scrollbar_track_border: Option<String>,
 633
 634    /// The color of the minimap thumb.
 635    #[serde(rename = "minimap.thumb.background")]
 636    pub minimap_thumb_background: Option<String>,
 637
 638    /// The color of the minimap thumb when hovered over.
 639    #[serde(rename = "minimap.thumb.hover_background")]
 640    pub minimap_thumb_hover_background: Option<String>,
 641
 642    /// The color of the minimap thumb whilst being actively dragged.
 643    #[serde(rename = "minimap.thumb.active_background")]
 644    pub minimap_thumb_active_background: Option<String>,
 645
 646    /// The border color of the minimap thumb.
 647    #[serde(rename = "minimap.thumb.border")]
 648    pub minimap_thumb_border: Option<String>,
 649
 650    #[serde(rename = "editor.foreground")]
 651    pub editor_foreground: Option<String>,
 652
 653    #[serde(rename = "editor.background")]
 654    pub editor_background: Option<String>,
 655
 656    #[serde(rename = "editor.gutter.background")]
 657    pub editor_gutter_background: Option<String>,
 658
 659    #[serde(rename = "editor.subheader.background")]
 660    pub editor_subheader_background: Option<String>,
 661
 662    #[serde(rename = "editor.active_line.background")]
 663    pub editor_active_line_background: Option<String>,
 664
 665    #[serde(rename = "editor.highlighted_line.background")]
 666    pub editor_highlighted_line_background: Option<String>,
 667
 668    /// Background of active line of debugger
 669    #[serde(rename = "editor.debugger_active_line.background")]
 670    pub editor_debugger_active_line_background: Option<String>,
 671
 672    /// Text Color. Used for the text of the line number in the editor gutter.
 673    #[serde(rename = "editor.line_number")]
 674    pub editor_line_number: Option<String>,
 675
 676    /// Text Color. Used for the text of the line number in the editor gutter when the line is highlighted.
 677    #[serde(rename = "editor.active_line_number")]
 678    pub editor_active_line_number: Option<String>,
 679
 680    /// Text Color. Used for the text of the line number in the editor gutter when the line is hovered over.
 681    #[serde(rename = "editor.hover_line_number")]
 682    pub editor_hover_line_number: Option<String>,
 683
 684    /// Text Color. Used to mark invisible characters in the editor.
 685    ///
 686    /// Example: spaces, tabs, carriage returns, etc.
 687    #[serde(rename = "editor.invisible")]
 688    pub editor_invisible: Option<String>,
 689
 690    #[serde(rename = "editor.wrap_guide")]
 691    pub editor_wrap_guide: Option<String>,
 692
 693    #[serde(rename = "editor.active_wrap_guide")]
 694    pub editor_active_wrap_guide: Option<String>,
 695
 696    #[serde(rename = "editor.indent_guide")]
 697    pub editor_indent_guide: Option<String>,
 698
 699    #[serde(rename = "editor.indent_guide_active")]
 700    pub editor_indent_guide_active: Option<String>,
 701
 702    /// Read-access of a symbol, like reading a variable.
 703    ///
 704    /// A document highlight is a range inside a text document which deserves
 705    /// special attention. Usually a document highlight is visualized by changing
 706    /// the background color of its range.
 707    #[serde(rename = "editor.document_highlight.read_background")]
 708    pub editor_document_highlight_read_background: Option<String>,
 709
 710    /// Read-access of a symbol, like reading a variable.
 711    ///
 712    /// A document highlight is a range inside a text document which deserves
 713    /// special attention. Usually a document highlight is visualized by changing
 714    /// the background color of its range.
 715    #[serde(rename = "editor.document_highlight.write_background")]
 716    pub editor_document_highlight_write_background: Option<String>,
 717
 718    /// Highlighted brackets background color.
 719    ///
 720    /// Matching brackets in the cursor scope are highlighted with this background color.
 721    #[serde(rename = "editor.document_highlight.bracket_background")]
 722    pub editor_document_highlight_bracket_background: Option<String>,
 723
 724    /// Terminal background color.
 725    #[serde(rename = "terminal.background")]
 726    pub terminal_background: Option<String>,
 727
 728    /// Terminal foreground color.
 729    #[serde(rename = "terminal.foreground")]
 730    pub terminal_foreground: Option<String>,
 731
 732    /// Terminal ANSI background color.
 733    #[serde(rename = "terminal.ansi.background")]
 734    pub terminal_ansi_background: Option<String>,
 735
 736    /// Bright terminal foreground color.
 737    #[serde(rename = "terminal.bright_foreground")]
 738    pub terminal_bright_foreground: Option<String>,
 739
 740    /// Dim terminal foreground color.
 741    #[serde(rename = "terminal.dim_foreground")]
 742    pub terminal_dim_foreground: Option<String>,
 743
 744    /// Black ANSI terminal color.
 745    #[serde(rename = "terminal.ansi.black")]
 746    pub terminal_ansi_black: Option<String>,
 747
 748    /// Bright black ANSI terminal color.
 749    #[serde(rename = "terminal.ansi.bright_black")]
 750    pub terminal_ansi_bright_black: Option<String>,
 751
 752    /// Dim black ANSI terminal color.
 753    #[serde(rename = "terminal.ansi.dim_black")]
 754    pub terminal_ansi_dim_black: Option<String>,
 755
 756    /// Red ANSI terminal color.
 757    #[serde(rename = "terminal.ansi.red")]
 758    pub terminal_ansi_red: Option<String>,
 759
 760    /// Bright red ANSI terminal color.
 761    #[serde(rename = "terminal.ansi.bright_red")]
 762    pub terminal_ansi_bright_red: Option<String>,
 763
 764    /// Dim red ANSI terminal color.
 765    #[serde(rename = "terminal.ansi.dim_red")]
 766    pub terminal_ansi_dim_red: Option<String>,
 767
 768    /// Green ANSI terminal color.
 769    #[serde(rename = "terminal.ansi.green")]
 770    pub terminal_ansi_green: Option<String>,
 771
 772    /// Bright green ANSI terminal color.
 773    #[serde(rename = "terminal.ansi.bright_green")]
 774    pub terminal_ansi_bright_green: Option<String>,
 775
 776    /// Dim green ANSI terminal color.
 777    #[serde(rename = "terminal.ansi.dim_green")]
 778    pub terminal_ansi_dim_green: Option<String>,
 779
 780    /// Yellow ANSI terminal color.
 781    #[serde(rename = "terminal.ansi.yellow")]
 782    pub terminal_ansi_yellow: Option<String>,
 783
 784    /// Bright yellow ANSI terminal color.
 785    #[serde(rename = "terminal.ansi.bright_yellow")]
 786    pub terminal_ansi_bright_yellow: Option<String>,
 787
 788    /// Dim yellow ANSI terminal color.
 789    #[serde(rename = "terminal.ansi.dim_yellow")]
 790    pub terminal_ansi_dim_yellow: Option<String>,
 791
 792    /// Blue ANSI terminal color.
 793    #[serde(rename = "terminal.ansi.blue")]
 794    pub terminal_ansi_blue: Option<String>,
 795
 796    /// Bright blue ANSI terminal color.
 797    #[serde(rename = "terminal.ansi.bright_blue")]
 798    pub terminal_ansi_bright_blue: Option<String>,
 799
 800    /// Dim blue ANSI terminal color.
 801    #[serde(rename = "terminal.ansi.dim_blue")]
 802    pub terminal_ansi_dim_blue: Option<String>,
 803
 804    /// Magenta ANSI terminal color.
 805    #[serde(rename = "terminal.ansi.magenta")]
 806    pub terminal_ansi_magenta: Option<String>,
 807
 808    /// Bright magenta ANSI terminal color.
 809    #[serde(rename = "terminal.ansi.bright_magenta")]
 810    pub terminal_ansi_bright_magenta: Option<String>,
 811
 812    /// Dim magenta ANSI terminal color.
 813    #[serde(rename = "terminal.ansi.dim_magenta")]
 814    pub terminal_ansi_dim_magenta: Option<String>,
 815
 816    /// Cyan ANSI terminal color.
 817    #[serde(rename = "terminal.ansi.cyan")]
 818    pub terminal_ansi_cyan: Option<String>,
 819
 820    /// Bright cyan ANSI terminal color.
 821    #[serde(rename = "terminal.ansi.bright_cyan")]
 822    pub terminal_ansi_bright_cyan: Option<String>,
 823
 824    /// Dim cyan ANSI terminal color.
 825    #[serde(rename = "terminal.ansi.dim_cyan")]
 826    pub terminal_ansi_dim_cyan: Option<String>,
 827
 828    /// White ANSI terminal color.
 829    #[serde(rename = "terminal.ansi.white")]
 830    pub terminal_ansi_white: Option<String>,
 831
 832    /// Bright white ANSI terminal color.
 833    #[serde(rename = "terminal.ansi.bright_white")]
 834    pub terminal_ansi_bright_white: Option<String>,
 835
 836    /// Dim white ANSI terminal color.
 837    #[serde(rename = "terminal.ansi.dim_white")]
 838    pub terminal_ansi_dim_white: Option<String>,
 839
 840    #[serde(rename = "link_text.hover")]
 841    pub link_text_hover: Option<String>,
 842
 843    /// Added version control color.
 844    #[serde(rename = "version_control.added")]
 845    pub version_control_added: Option<String>,
 846
 847    /// Deleted version control color.
 848    #[serde(rename = "version_control.deleted")]
 849    pub version_control_deleted: Option<String>,
 850
 851    /// Modified version control color.
 852    #[serde(rename = "version_control.modified")]
 853    pub version_control_modified: Option<String>,
 854
 855    /// Renamed version control color.
 856    #[serde(rename = "version_control.renamed")]
 857    pub version_control_renamed: Option<String>,
 858
 859    /// Conflict version control color.
 860    #[serde(rename = "version_control.conflict")]
 861    pub version_control_conflict: Option<String>,
 862
 863    /// Ignored version control color.
 864    #[serde(rename = "version_control.ignored")]
 865    pub version_control_ignored: Option<String>,
 866
 867    /// Color for added words in word diffs.
 868    #[serde(rename = "version_control.word_added")]
 869    pub version_control_word_added: Option<String>,
 870
 871    /// Color for deleted words in word diffs.
 872    #[serde(rename = "version_control.word_deleted")]
 873    pub version_control_word_deleted: Option<String>,
 874
 875    /// Background color for row highlights of "ours" regions in merge conflicts.
 876    #[serde(rename = "version_control.conflict_marker.ours")]
 877    pub version_control_conflict_marker_ours: Option<String>,
 878
 879    /// Background color for row highlights of "theirs" regions in merge conflicts.
 880    #[serde(rename = "version_control.conflict_marker.theirs")]
 881    pub version_control_conflict_marker_theirs: Option<String>,
 882
 883    /// Deprecated in favor of `version_control_conflict_marker_ours`.
 884    #[deprecated]
 885    pub version_control_conflict_ours_background: Option<String>,
 886
 887    /// Deprecated in favor of `version_control_conflict_marker_theirs`.
 888    #[deprecated]
 889    pub version_control_conflict_theirs_background: Option<String>,
 890
 891    /// Background color for Vim Normal mode indicator.
 892    #[serde(rename = "vim.normal.background")]
 893    pub vim_normal_background: Option<String>,
 894    /// Background color for Vim Insert mode indicator.
 895    #[serde(rename = "vim.insert.background")]
 896    pub vim_insert_background: Option<String>,
 897    /// Background color for Vim Replace mode indicator.
 898    #[serde(rename = "vim.replace.background")]
 899    pub vim_replace_background: Option<String>,
 900    /// Background color for Vim Visual mode indicator.
 901    #[serde(rename = "vim.visual.background")]
 902    pub vim_visual_background: Option<String>,
 903    /// Background color for Vim Visual Line mode indicator.
 904    #[serde(rename = "vim.visual_line.background")]
 905    pub vim_visual_line_background: Option<String>,
 906    /// Background color for Vim Visual Block mode indicator.
 907    #[serde(rename = "vim.visual_block.background")]
 908    pub vim_visual_block_background: Option<String>,
 909    /// Background color for Vim Helix Normal mode indicator.
 910    #[serde(rename = "vim.helix_normal.background")]
 911    pub vim_helix_normal_background: Option<String>,
 912    /// Background color for Vim Helix Select mode indicator.
 913    #[serde(rename = "vim.helix_select.background")]
 914    pub vim_helix_select_background: Option<String>,
 915
 916    /// Text color for Vim mode indicator label.
 917    #[serde(rename = "vim.mode.text")]
 918    pub vim_mode_text: Option<String>,
 919}
 920
 921#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
 922#[serde(default)]
 923pub struct HighlightStyleContent {
 924    pub color: Option<String>,
 925
 926    #[serde(
 927        skip_serializing_if = "Option::is_none",
 928        deserialize_with = "treat_error_as_none"
 929    )]
 930    pub background_color: Option<String>,
 931
 932    #[serde(
 933        skip_serializing_if = "Option::is_none",
 934        deserialize_with = "treat_error_as_none"
 935    )]
 936    pub font_style: Option<FontStyleContent>,
 937
 938    #[serde(
 939        skip_serializing_if = "Option::is_none",
 940        deserialize_with = "treat_error_as_none"
 941    )]
 942    pub font_weight: Option<FontWeightContent>,
 943}
 944
 945impl HighlightStyleContent {
 946    pub fn is_empty(&self) -> bool {
 947        self.color.is_none()
 948            && self.background_color.is_none()
 949            && self.font_style.is_none()
 950            && self.font_weight.is_none()
 951    }
 952}
 953
 954fn treat_error_as_none<'de, T, D>(deserializer: D) -> Result<Option<T>, D::Error>
 955where
 956    T: Deserialize<'de>,
 957    D: Deserializer<'de>,
 958{
 959    let value: Value = Deserialize::deserialize(deserializer)?;
 960    Ok(T::deserialize(value).ok())
 961}
 962
 963#[with_fallible_options]
 964#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
 965#[serde(default)]
 966pub struct StatusColorsContent {
 967    /// Indicates some kind of conflict, like a file changed on disk while it was open, or
 968    /// merge conflicts in a Git repository.
 969    #[serde(rename = "conflict")]
 970    pub conflict: Option<String>,
 971
 972    #[serde(rename = "conflict.background")]
 973    pub conflict_background: Option<String>,
 974
 975    #[serde(rename = "conflict.border")]
 976    pub conflict_border: Option<String>,
 977
 978    /// Indicates something new, like a new file added to a Git repository.
 979    #[serde(rename = "created")]
 980    pub created: Option<String>,
 981
 982    #[serde(rename = "created.background")]
 983    pub created_background: Option<String>,
 984
 985    #[serde(rename = "created.border")]
 986    pub created_border: Option<String>,
 987
 988    /// Indicates that something no longer exists, like a deleted file.
 989    #[serde(rename = "deleted")]
 990    pub deleted: Option<String>,
 991
 992    #[serde(rename = "deleted.background")]
 993    pub deleted_background: Option<String>,
 994
 995    #[serde(rename = "deleted.border")]
 996    pub deleted_border: Option<String>,
 997
 998    /// Indicates a system error, a failed operation or a diagnostic error.
 999    #[serde(rename = "error")]
1000    pub error: Option<String>,
1001
1002    #[serde(rename = "error.background")]
1003    pub error_background: Option<String>,
1004
1005    #[serde(rename = "error.border")]
1006    pub error_border: Option<String>,
1007
1008    /// Represents a hidden status, such as a file being hidden in a file tree.
1009    #[serde(rename = "hidden")]
1010    pub hidden: Option<String>,
1011
1012    #[serde(rename = "hidden.background")]
1013    pub hidden_background: Option<String>,
1014
1015    #[serde(rename = "hidden.border")]
1016    pub hidden_border: Option<String>,
1017
1018    /// Indicates a hint or some kind of additional information.
1019    #[serde(rename = "hint")]
1020    pub hint: Option<String>,
1021
1022    #[serde(rename = "hint.background")]
1023    pub hint_background: Option<String>,
1024
1025    #[serde(rename = "hint.border")]
1026    pub hint_border: Option<String>,
1027
1028    /// Indicates that something is deliberately ignored, such as a file or operation ignored by Git.
1029    #[serde(rename = "ignored")]
1030    pub ignored: Option<String>,
1031
1032    #[serde(rename = "ignored.background")]
1033    pub ignored_background: Option<String>,
1034
1035    #[serde(rename = "ignored.border")]
1036    pub ignored_border: Option<String>,
1037
1038    /// Represents informational status updates or messages.
1039    #[serde(rename = "info")]
1040    pub info: Option<String>,
1041
1042    #[serde(rename = "info.background")]
1043    pub info_background: Option<String>,
1044
1045    #[serde(rename = "info.border")]
1046    pub info_border: Option<String>,
1047
1048    /// Indicates a changed or altered status, like a file that has been edited.
1049    #[serde(rename = "modified")]
1050    pub modified: Option<String>,
1051
1052    #[serde(rename = "modified.background")]
1053    pub modified_background: Option<String>,
1054
1055    #[serde(rename = "modified.border")]
1056    pub modified_border: Option<String>,
1057
1058    /// Indicates something that is predicted, like automatic code completion, or generated code.
1059    #[serde(rename = "predictive")]
1060    pub predictive: Option<String>,
1061
1062    #[serde(rename = "predictive.background")]
1063    pub predictive_background: Option<String>,
1064
1065    #[serde(rename = "predictive.border")]
1066    pub predictive_border: Option<String>,
1067
1068    /// Represents a renamed status, such as a file that has been renamed.
1069    #[serde(rename = "renamed")]
1070    pub renamed: Option<String>,
1071
1072    #[serde(rename = "renamed.background")]
1073    pub renamed_background: Option<String>,
1074
1075    #[serde(rename = "renamed.border")]
1076    pub renamed_border: Option<String>,
1077
1078    /// Indicates a successful operation or task completion.
1079    #[serde(rename = "success")]
1080    pub success: Option<String>,
1081
1082    #[serde(rename = "success.background")]
1083    pub success_background: Option<String>,
1084
1085    #[serde(rename = "success.border")]
1086    pub success_border: Option<String>,
1087
1088    /// Indicates some kind of unreachable status, like a block of code that can never be reached.
1089    #[serde(rename = "unreachable")]
1090    pub unreachable: Option<String>,
1091
1092    #[serde(rename = "unreachable.background")]
1093    pub unreachable_background: Option<String>,
1094
1095    #[serde(rename = "unreachable.border")]
1096    pub unreachable_border: Option<String>,
1097
1098    /// Represents a warning status, like an operation that is about to fail.
1099    #[serde(rename = "warning")]
1100    pub warning: Option<String>,
1101
1102    #[serde(rename = "warning.background")]
1103    pub warning_background: Option<String>,
1104
1105    #[serde(rename = "warning.border")]
1106    pub warning_border: Option<String>,
1107}
1108
1109/// The background appearance of the window.
1110#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize, JsonSchema, MergeFrom)]
1111#[serde(rename_all = "snake_case")]
1112pub enum WindowBackgroundContent {
1113    Opaque,
1114    Transparent,
1115    Blurred,
1116}
1117
1118impl Into<gpui::WindowBackgroundAppearance> for WindowBackgroundContent {
1119    fn into(self) -> gpui::WindowBackgroundAppearance {
1120        match self {
1121            WindowBackgroundContent::Opaque => gpui::WindowBackgroundAppearance::Opaque,
1122            WindowBackgroundContent::Transparent => gpui::WindowBackgroundAppearance::Transparent,
1123            WindowBackgroundContent::Blurred => gpui::WindowBackgroundAppearance::Blurred,
1124        }
1125    }
1126}
1127
1128#[derive(Debug, Clone, Copy, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq)]
1129#[serde(rename_all = "snake_case")]
1130pub enum FontStyleContent {
1131    Normal,
1132    Italic,
1133    Oblique,
1134}
1135
1136impl From<FontStyleContent> for FontStyle {
1137    fn from(value: FontStyleContent) -> Self {
1138        match value {
1139            FontStyleContent::Normal => FontStyle::Normal,
1140            FontStyleContent::Italic => FontStyle::Italic,
1141            FontStyleContent::Oblique => FontStyle::Oblique,
1142        }
1143    }
1144}
1145
1146#[derive(
1147    Debug, Clone, Copy, Serialize_repr, Deserialize_repr, JsonSchema_repr, PartialEq, MergeFrom,
1148)]
1149#[repr(u16)]
1150pub enum FontWeightContent {
1151    Thin = 100,
1152    ExtraLight = 200,
1153    Light = 300,
1154    Normal = 400,
1155    Medium = 500,
1156    Semibold = 600,
1157    Bold = 700,
1158    ExtraBold = 800,
1159    Black = 900,
1160}
1161
1162impl From<FontWeightContent> for FontWeight {
1163    fn from(value: FontWeightContent) -> Self {
1164        match value {
1165            FontWeightContent::Thin => FontWeight::THIN,
1166            FontWeightContent::ExtraLight => FontWeight::EXTRA_LIGHT,
1167            FontWeightContent::Light => FontWeight::LIGHT,
1168            FontWeightContent::Normal => FontWeight::NORMAL,
1169            FontWeightContent::Medium => FontWeight::MEDIUM,
1170            FontWeightContent::Semibold => FontWeight::SEMIBOLD,
1171            FontWeightContent::Bold => FontWeight::BOLD,
1172            FontWeightContent::ExtraBold => FontWeight::EXTRA_BOLD,
1173            FontWeightContent::Black => FontWeight::BLACK,
1174        }
1175    }
1176}
1177
1178#[cfg(test)]
1179mod tests {
1180    use super::*;
1181    use serde_json::json;
1182
1183    #[test]
1184    fn test_buffer_line_height_deserialize_valid() {
1185        assert_eq!(
1186            serde_json::from_value::<BufferLineHeight>(json!("comfortable")).unwrap(),
1187            BufferLineHeight::Comfortable
1188        );
1189        assert_eq!(
1190            serde_json::from_value::<BufferLineHeight>(json!("standard")).unwrap(),
1191            BufferLineHeight::Standard
1192        );
1193        assert_eq!(
1194            serde_json::from_value::<BufferLineHeight>(json!({"custom": 1.0})).unwrap(),
1195            BufferLineHeight::Custom(1.0)
1196        );
1197        assert_eq!(
1198            serde_json::from_value::<BufferLineHeight>(json!({"custom": 1.5})).unwrap(),
1199            BufferLineHeight::Custom(1.5)
1200        );
1201    }
1202
1203    #[test]
1204    fn test_buffer_line_height_deserialize_invalid() {
1205        assert!(
1206            serde_json::from_value::<BufferLineHeight>(json!({"custom": 0.99}))
1207                .err()
1208                .unwrap()
1209                .to_string()
1210                .contains("buffer_line_height.custom must be at least 1.0")
1211        );
1212        assert!(
1213            serde_json::from_value::<BufferLineHeight>(json!({"custom": 0.0}))
1214                .err()
1215                .unwrap()
1216                .to_string()
1217                .contains("buffer_line_height.custom must be at least 1.0")
1218        );
1219        assert!(
1220            serde_json::from_value::<BufferLineHeight>(json!({"custom": -1.0}))
1221                .err()
1222                .unwrap()
1223                .to_string()
1224                .contains("buffer_line_height.custom must be at least 1.0")
1225        );
1226    }
1227
1228    #[test]
1229    fn test_buffer_font_weight_schema_has_default() {
1230        use schemars::schema_for;
1231
1232        let schema = schema_for!(ThemeSettingsContent);
1233        let schema_value = serde_json::to_value(&schema).unwrap();
1234
1235        let properties = &schema_value["properties"];
1236        let buffer_font_weight = &properties["buffer_font_weight"];
1237
1238        assert!(
1239            buffer_font_weight.get("default").is_some(),
1240            "buffer_font_weight should have a default value in the schema"
1241        );
1242
1243        let default_value = &buffer_font_weight["default"];
1244        assert_eq!(
1245            default_value.as_f64(),
1246            Some(FontWeight::NORMAL.0 as f64),
1247            "buffer_font_weight default should be 400.0 (FontWeight::NORMAL)"
1248        );
1249
1250        let defs = &schema_value["$defs"];
1251        let font_weight_def = &defs["FontWeight"];
1252
1253        assert_eq!(
1254            font_weight_def["minimum"].as_f64(),
1255            Some(FontWeight::THIN.0 as f64),
1256            "FontWeight should have minimum of 100.0"
1257        );
1258        assert_eq!(
1259            font_weight_def["maximum"].as_f64(),
1260            Some(FontWeight::BLACK.0 as f64),
1261            "FontWeight should have maximum of 900.0"
1262        );
1263        assert_eq!(
1264            font_weight_def["default"].as_f64(),
1265            Some(FontWeight::NORMAL.0 as f64),
1266            "FontWeight should have default of 400.0"
1267        );
1268    }
1269}