From 33b5a900197e2798a393d6d9a0834039666eddbb Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 19 Apr 2023 01:19:56 +0200 Subject: Make basic text shaping the default shaping strategy --- widget/src/checkbox.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'widget/src/checkbox.rs') diff --git a/widget/src/checkbox.rs b/widget/src/checkbox.rs index 6505cfdd..e28f76af 100644 --- a/widget/src/checkbox.rs +++ b/widget/src/checkbox.rs @@ -273,6 +273,7 @@ where color: custom_style.icon_color, horizontal_alignment: alignment::Horizontal::Center, vertical_alignment: alignment::Vertical::Center, + advanced_shape: true, }); } } @@ -292,6 +293,7 @@ where }, alignment::Horizontal::Left, alignment::Vertical::Center, + false, ); } } -- cgit From 4bd290afe7d81d9aaf7467b3ce91491f6600261a Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 19 Apr 2023 02:00:45 +0200 Subject: Introduce `text::Shaping` enum and replace magic boolean --- widget/src/checkbox.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'widget/src/checkbox.rs') diff --git a/widget/src/checkbox.rs b/widget/src/checkbox.rs index e28f76af..2a09b8fd 100644 --- a/widget/src/checkbox.rs +++ b/widget/src/checkbox.rs @@ -46,6 +46,7 @@ where size: f32, spacing: f32, text_size: Option, + text_shaping: text::Shaping, font: Option, icon: Icon, style: ::Style, @@ -82,11 +83,13 @@ where size: Self::DEFAULT_SIZE, spacing: Self::DEFAULT_SPACING, text_size: None, + text_shaping: text::Shaping::Basic, font: None, icon: Icon { font: Renderer::ICON_FONT, code_point: Renderer::CHECKMARK_ICON, size: None, + shaping: text::Shaping::Basic, }, style: Default::default(), } @@ -116,6 +119,12 @@ where self } + /// Sets the [`text::Shaping`] strategy of the [`Checkbox`]. + pub fn text_shaping(mut self, shaping: text::Shaping) -> Self { + self.text_shaping = shaping; + self + } + /// Sets the [`Font`] of the text of the [`Checkbox`]. /// /// [`Font`]: crate::text::Renderer::Font @@ -171,7 +180,8 @@ where .size( self.text_size .unwrap_or_else(|| renderer.default_size()), - ), + ) + .shaping(self.text_shaping), ) .layout(renderer, limits) } @@ -257,6 +267,7 @@ where font, code_point, size, + shaping, } = &self.icon; let size = size.unwrap_or(bounds.height * 0.7); @@ -273,7 +284,7 @@ where color: custom_style.icon_color, horizontal_alignment: alignment::Horizontal::Center, vertical_alignment: alignment::Vertical::Center, - advanced_shape: true, + shaping: *shaping, }); } } @@ -293,7 +304,7 @@ where }, alignment::Horizontal::Left, alignment::Vertical::Center, - false, + self.text_shaping, ); } } @@ -322,4 +333,6 @@ pub struct Icon { pub code_point: char, /// Font size of the content. pub size: Option, + /// The shaping strategy of the icon. + pub shaping: text::Shaping, } -- cgit