Merge pull request #2988 from andymandias/text-font_maybe

Add `font_maybe` Utility Function to `Text`
This commit is contained in:
Héctor 2025-11-27 04:42:50 +01:00 committed by GitHub
commit d94c080dd4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -99,6 +99,17 @@ where
self
}
/// Sets the [`Font`] of the [`Text`], if `Some`.
///
/// [`Font`]: crate::text::Renderer::Font
pub fn font_maybe(
mut self,
font: Option<impl Into<Renderer::Font>>,
) -> Self {
self.format.font = font.map(Into::into);
self
}
/// Sets the width of the [`Text`] boundaries.
pub fn width(mut self, width: impl Into<Length>) -> Self {
self.format.width = width.into();