Replace Program::fonts with simpler font method

This commit is contained in:
Héctor Ramón Jiménez 2024-03-16 16:58:48 +01:00
parent bad3b1ac47
commit cfc0383bbf
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 5 additions and 13 deletions

View file

@ -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()
}

View file

@ -312,18 +312,10 @@ impl<P: Definition> Program<P> {
}
}
/// Sets the fonts that will be loaded at the start of the [`Program`].
pub fn fonts(
self,
fonts: impl IntoIterator<Item = Cow<'static, [u8]>>,
) -> 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<Cow<'static, [u8]>>) -> Self {
self.settings.fonts.push(font.into());
self
}
/// Sets the [`window::Settings::position`] to [`window::Position::Centered`] in the [`Program`].