Skip to content

Commit d94c080

Browse files
authored
Merge pull request #2988 from andymandias/text-font_maybe
Add `font_maybe` Utility Function to `Text`
2 parents b3e1be5 + c82f97c commit d94c080

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

core/src/widget/text.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ where
9999
self
100100
}
101101

102+
/// Sets the [`Font`] of the [`Text`], if `Some`.
103+
///
104+
/// [`Font`]: crate::text::Renderer::Font
105+
pub fn font_maybe(
106+
mut self,
107+
font: Option<impl Into<Renderer::Font>>,
108+
) -> Self {
109+
self.format.font = font.map(Into::into);
110+
self
111+
}
112+
102113
/// Sets the width of the [`Text`] boundaries.
103114
pub fn width(mut self, width: impl Into<Length>) -> Self {
104115
self.format.width = width.into();

0 commit comments

Comments
 (0)