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

@ -43,6 +43,7 @@ where
size: f32,
text_size: Option<f32>,
text_alignment: alignment::Horizontal,
text_shaping: text::Shaping,
spacing: f32,
font: Option<Renderer::Font>,
style: <Renderer::Theme as StyleSheet>::Style,
@ -80,6 +81,7 @@ where
size: Self::DEFAULT_SIZE,
text_size: None,
text_alignment: alignment::Horizontal::Left,
text_shaping: text::Shaping::Basic,
spacing: 0.0,
font: None,
style: Default::default(),
@ -110,6 +112,12 @@ where
self
}
/// Sets the [`text::Shaping`] strategy of the [`Toggler`].
pub fn text_shaping(mut self, shaping: text::Shaping) -> Self {
self.text_shaping = shaping;
self
}
/// Sets the spacing between the [`Toggler`] and the text.
pub fn spacing(mut self, spacing: impl Into<Pixels>) -> Self {
self.spacing = spacing.into().0;
@ -167,7 +175,8 @@ where
.size(
self.text_size
.unwrap_or_else(|| renderer.default_size()),
),
)
.shaping(self.text_shaping),
);
}
@ -249,7 +258,7 @@ where
Default::default(),
self.text_alignment,
alignment::Vertical::Center,
false,
self.text_shaping,
);
}