From ea469474893496588204902abb92c47b3c57e8bd Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Mon, 19 Jun 2023 11:36:42 -0700 Subject: [PATCH] Tidy up font schema a little --- crates/gpui/src/fonts.rs | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/crates/gpui/src/fonts.rs b/crates/gpui/src/fonts.rs index 62894452fd115312833b0ca51482dc98aa138253..3b4a94dd0e69137ab95457d3991f88e245758243 100644 --- a/crates/gpui/src/fonts.rs +++ b/crates/gpui/src/fonts.rs @@ -66,7 +66,7 @@ pub struct TextStyle { pub font_family_id: FamilyId, pub font_id: FontId, pub font_size: f32, - #[serde(with = "PropertiesDef")] + #[schemars(with = "PropertiesDef")] pub font_properties: Properties, pub underline: Underline, } @@ -77,13 +77,13 @@ pub struct PropertiesDef { /// The font style, as defined in CSS. pub style: StyleDef, /// The font weight, as defined in CSS. - pub weight: WeightDef, + pub weight: f32, /// The font stretchiness, as defined in CSS. - pub stretch: StretchDef, + pub stretch: f32, } #[derive(JsonSchema)] -#[serde(remote = "Style")] +#[schemars(remote = "Style")] pub enum StyleDef { /// A face that is neither italic not obliqued. Normal, @@ -93,18 +93,10 @@ pub enum StyleDef { Oblique, } -#[derive(JsonSchema)] -#[serde(remote = "Weight")] -pub struct WeightDef(pub f32); - -#[derive(JsonSchema)] -#[serde(remote = "Stretch")] -pub struct StretchDef(pub f32); - #[derive(Copy, Clone, Debug, Default, PartialEq, JsonSchema)] pub struct HighlightStyle { pub color: Option, - #[serde(with = "WeightDef")] + #[schemars(with = "Option::")] pub weight: Option, pub italic: Option, pub underline: Option, @@ -116,15 +108,11 @@ impl Eq for HighlightStyle {} #[derive(Copy, Clone, Debug, Default, PartialEq, Eq, JsonSchema)] pub struct Underline { pub color: Option, - #[serde(with = "OrderedFloatDef::")] + #[schemars(with = "f32")] pub thickness: OrderedFloat, pub squiggly: bool, } -#[derive(JsonSchema)] -#[serde(remote = "OrderedFloat")] -pub struct OrderedFloatDef(pub T); - #[allow(non_camel_case_types)] #[derive(Deserialize)] enum WeightJson {