From c82f97c8c990e88561a5e978d2736eb1932f97e8 Mon Sep 17 00:00:00 2001 From: Andrew Baldwin Date: Thu, 12 Jun 2025 13:02:38 -0700 Subject: [PATCH] Add `font_maybe` to `Text`. --- core/src/widget/text.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/src/widget/text.rs b/core/src/widget/text.rs index 72cb4319..2acaa821 100644 --- a/core/src/widget/text.rs +++ b/core/src/widget/text.rs @@ -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>, + ) -> Self { + self.format.font = font.map(Into::into); + self + } + /// Sets the width of the [`Text`] boundaries. pub fn width(mut self, width: impl Into) -> Self { self.format.width = width.into();