From cfc0383bbfff083786840e3f1fd499e5991fa629 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 16 Mar 2024 16:58:48 +0100 Subject: Replace `Program::fonts` with simpler `font` method --- examples/checkbox/src/main.rs | 2 +- src/program.rs | 16 ++++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/examples/checkbox/src/main.rs b/examples/checkbox/src/main.rs index c9ee502e..8d18cb81 100644 --- a/examples/checkbox/src/main.rs +++ b/examples/checkbox/src/main.rs @@ -5,7 +5,7 @@ const ICON_FONT: Font = Font::with_name("icons"); pub fn main() -> iced::Result { iced::sandbox("Checkbox - Iced", Example::update, Example::view) - .fonts([include_bytes!("../fonts/icons.ttf").as_slice().into()]) + .font(include_bytes!("../fonts/icons.ttf").as_slice()) .run() } diff --git a/src/program.rs b/src/program.rs index c6c702f1..37ff64b1 100644 --- a/src/program.rs +++ b/src/program.rs @@ -312,18 +312,10 @@ impl Program

{ } } - /// Sets the fonts that will be loaded at the start of the [`Program`]. - pub fn fonts( - self, - fonts: impl IntoIterator>, - ) -> Self { - Self { - settings: Settings { - fonts: fonts.into_iter().collect(), - ..self.settings - }, - ..self - } + /// Adds a font to the list of fonts that will be loaded at the start of the [`Program`]. + pub fn font(mut self, font: impl Into>) -> Self { + self.settings.fonts.push(font.into()); + self } /// Sets the [`window::Settings::position`] to [`window::Position::Centered`] in the [`Program`]. -- cgit