From 700262e05c76e003158acfeb8edd9f6b026d78cf Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 24 Feb 2023 13:56:37 +0100 Subject: Fix `checkbox` example --- examples/checkbox/src/main.rs | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'examples/checkbox/src') diff --git a/examples/checkbox/src/main.rs b/examples/checkbox/src/main.rs index 09950bb8..77111490 100644 --- a/examples/checkbox/src/main.rs +++ b/examples/checkbox/src/main.rs @@ -1,10 +1,9 @@ +use iced::executor; +use iced::font::{self, Font}; use iced::widget::{checkbox, column, container}; -use iced::{Element, Font, Length, Sandbox, Settings}; +use iced::{Application, Command, Element, Length, Settings, Theme}; -const ICON_FONT: Font = Font::External { - name: "Icons", - bytes: include_bytes!("../fonts/icons.ttf"), -}; +const ICON_FONT: Font = Font::Name("icons"); pub fn main() -> iced::Result { Example::run(Settings::default()) @@ -20,24 +19,35 @@ struct Example { enum Message { DefaultChecked(bool), CustomChecked(bool), + FontLoaded(Result<(), font::Error>), } -impl Sandbox for Example { +impl Application for Example { type Message = Message; + type Flags = (); + type Executor = executor::Default; + type Theme = Theme; - fn new() -> Self { - Default::default() + fn new(_flags: Self::Flags) -> (Self, Command) { + ( + Self::default(), + font::load(include_bytes!("../fonts/icons.ttf").as_ref()) + .map(Message::FontLoaded), + ) } fn title(&self) -> String { String::from("Checkbox - Iced") } - fn update(&mut self, message: Message) { + fn update(&mut self, message: Message) -> Command { match message { Message::DefaultChecked(value) => self.default_checkbox = value, Message::CustomChecked(value) => self.custom_checkbox = value, + Message::FontLoaded(_) => (), } + + Command::none() } fn view(&self) -> Element { -- cgit From 707de9d788dc3c49d4ac57a19afac1bb938b78d9 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 30 Mar 2023 00:56:00 +0200 Subject: Introduce support for `Font` attributes --- examples/checkbox/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/checkbox/src') diff --git a/examples/checkbox/src/main.rs b/examples/checkbox/src/main.rs index 77111490..c5f3c134 100644 --- a/examples/checkbox/src/main.rs +++ b/examples/checkbox/src/main.rs @@ -3,7 +3,7 @@ use iced::font::{self, Font}; use iced::widget::{checkbox, column, container}; use iced::{Application, Command, Element, Length, Settings, Theme}; -const ICON_FONT: Font = Font::Name("icons"); +const ICON_FONT: Font = Font::with_name("icons"); pub fn main() -> iced::Result { Example::run(Settings::default()) -- cgit From edf3432bf5176be13437b9fd5d25b890ec9dbe69 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 2 May 2023 00:58:33 +0200 Subject: Update `glyphon` and `cosmic-text` --- examples/checkbox/src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'examples/checkbox/src') diff --git a/examples/checkbox/src/main.rs b/examples/checkbox/src/main.rs index c5f3c134..5852e978 100644 --- a/examples/checkbox/src/main.rs +++ b/examples/checkbox/src/main.rs @@ -1,6 +1,6 @@ use iced::executor; use iced::font::{self, Font}; -use iced::widget::{checkbox, column, container}; +use iced::widget::{checkbox, column, container, text}; use iced::{Application, Command, Element, Length, Settings, Theme}; const ICON_FONT: Font = Font::with_name("icons"); @@ -59,6 +59,7 @@ impl Application for Example { font: ICON_FONT, code_point: '\u{e901}', size: None, + shaping: text::Shaping::Basic, }); let content = column![default_checkbox, custom_checkbox].spacing(22); -- cgit From 180cb073bdb1429e566839b09d6fe86114c83673 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 8 May 2023 16:19:28 +0200 Subject: Add `line_height` to `checkbox::Icon` --- examples/checkbox/src/main.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'examples/checkbox/src') diff --git a/examples/checkbox/src/main.rs b/examples/checkbox/src/main.rs index 5852e978..ef61a974 100644 --- a/examples/checkbox/src/main.rs +++ b/examples/checkbox/src/main.rs @@ -59,6 +59,7 @@ impl Application for Example { font: ICON_FONT, code_point: '\u{e901}', size: None, + line_height: text::LineHeight::Relative(1.0), shaping: text::Shaping::Basic, }); -- cgit