diff options
author | 2023-02-04 07:33:33 +0100 | |
---|---|---|
committer | 2023-02-24 13:28:24 +0100 | |
commit | b29de28d1f0f608f8029c93d154cfd1b0f8b8cbb (patch) | |
tree | e100af1dd98d23b29046bc951b04b440d2aa5bc2 /native/src/widget/checkbox.rs | |
parent | a7580e0696a1a0ba76a89db3f78bc99ba3fbb361 (diff) | |
download | iced-b29de28d1f0f608f8029c93d154cfd1b0f8b8cbb.tar.gz iced-b29de28d1f0f608f8029c93d154cfd1b0f8b8cbb.tar.bz2 iced-b29de28d1f0f608f8029c93d154cfd1b0f8b8cbb.zip |
Overhaul `Font` type to allow font family selection
Diffstat (limited to 'native/src/widget/checkbox.rs')
-rw-r--r-- | native/src/widget/checkbox.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/native/src/widget/checkbox.rs b/native/src/widget/checkbox.rs index 9b69e574..138c458c 100644 --- a/native/src/widget/checkbox.rs +++ b/native/src/widget/checkbox.rs @@ -55,7 +55,7 @@ where size: f32, spacing: f32, text_size: Option<f32>, - font: Renderer::Font, + font: Option<Renderer::Font>, icon: Icon<Renderer::Font>, style: <Renderer::Theme as StyleSheet>::Style, } @@ -91,7 +91,7 @@ where size: Self::DEFAULT_SIZE, spacing: Self::DEFAULT_SPACING, text_size: None, - font: Renderer::Font::default(), + font: None, icon: Icon { font: Renderer::ICON_FONT, code_point: Renderer::CHECKMARK_ICON, @@ -128,8 +128,8 @@ where /// Sets the [`Font`] of the text of the [`Checkbox`]. /// /// [`Font`]: crate::text::Renderer::Font - pub fn font(mut self, font: Renderer::Font) -> Self { - self.font = font; + pub fn font(mut self, font: impl Into<Renderer::Font>) -> Self { + self.font = Some(font.into()); self } @@ -175,7 +175,7 @@ where .push(Row::new().width(self.size).height(self.size)) .push( Text::new(&self.label) - .font(self.font.clone()) + .font(self.font.unwrap_or_else(|| renderer.default_font())) .width(self.width) .size( self.text_size @@ -288,6 +288,7 @@ where { let label_layout = children.next().unwrap(); + let font = self.font.unwrap_or_else(|| renderer.default_font()); widget::text::draw( renderer, @@ -295,7 +296,7 @@ where label_layout, &self.label, self.text_size, - self.font.clone(), + font, widget::text::Appearance { color: custom_style.text_color, }, |