Introduce text::Shaping enum and replace magic boolean

This commit is contained in:
Héctor Ramón Jiménez 2023-04-19 02:00:45 +02:00
parent 33b5a90019
commit 4bd290afe7
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
25 changed files with 203 additions and 132 deletions

View file

@ -81,6 +81,7 @@ where
size: f32,
spacing: f32,
text_size: Option<f32>,
text_shaping: text::Shaping,
font: Option<Renderer::Font>,
style: <Renderer::Theme as StyleSheet>::Style,
}
@ -123,6 +124,7 @@ where
size: Self::DEFAULT_SIZE,
spacing: Self::DEFAULT_SPACING, //15
text_size: None,
text_shaping: text::Shaping::Basic,
font: None,
style: Default::default(),
}
@ -152,6 +154,12 @@ where
self
}
/// Sets the [`text::Shaping`] strategy of the [`Radio`] button.
pub fn text_shaping(mut self, shaping: text::Shaping) -> Self {
self.text_shaping = shaping;
self
}
/// Sets the text font of the [`Radio`] button.
pub fn font(mut self, font: impl Into<Renderer::Font>) -> Self {
self.font = Some(font.into());
@ -192,9 +200,15 @@ where
.spacing(self.spacing)
.align_items(Alignment::Center)
.push(Row::new().width(self.size).height(self.size))
.push(Text::new(&self.label).width(self.width).size(
self.text_size.unwrap_or_else(|| renderer.default_size()),
))
.push(
Text::new(&self.label)
.width(self.width)
.size(
self.text_size
.unwrap_or_else(|| renderer.default_size()),
)
.shaping(self.text_shaping),
)
.layout(renderer, limits)
}
@ -309,7 +323,7 @@ where
},
alignment::Horizontal::Left,
alignment::Vertical::Center,
false,
self.text_shaping,
);
}
}