summaryrefslogtreecommitdiffstats
path: root/core/src/text.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-07-18 13:14:56 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-07-18 13:14:56 +0200
commit904704d7c1b006c850654dcf3bf9e856e23cb317 (patch)
treef26c32d5769a184c72ca3dc4accacd1ac634d915 /core/src/text.rs
parent910eb72a0620b34e5b3d7793bbd5ab7290e08dd6 (diff)
downloadiced-904704d7c1b006c850654dcf3bf9e856e23cb317.tar.gz
iced-904704d7c1b006c850654dcf3bf9e856e23cb317.tar.bz2
iced-904704d7c1b006c850654dcf3bf9e856e23cb317.zip
Flesh out the `markdown` example a bit more
Diffstat (limited to 'core/src/text.rs')
-rw-r--r--core/src/text.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/src/text.rs b/core/src/text.rs
index d73eb94a..22cfce13 100644
--- a/core/src/text.rs
+++ b/core/src/text.rs
@@ -267,12 +267,24 @@ impl<'a, Font> Span<'a, Font> {
self
}
+ /// Sets the font of the [`Span`], if any.
+ pub fn font_maybe(mut self, font: Option<impl Into<Font>>) -> Self {
+ self.font = font.map(Into::into);
+ self
+ }
+
/// Sets the [`Color`] of the [`Span`].
pub fn color(mut self, color: impl Into<Color>) -> Self {
self.color = Some(color.into());
self
}
+ /// Sets the [`Color`] of the [`Span`], if any.
+ pub fn color_maybe(mut self, color: Option<impl Into<Color>>) -> Self {
+ self.color = color.map(Into::into);
+ self
+ }
+
/// Turns the [`Span`] into a static one.
pub fn to_static(self) -> Span<'static, Font> {
Span {