summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-02-22 08:45:12 +0000
committerJoe Carstairs <me@joeac.net>2026-02-22 08:45:12 +0000
commit376ad725248c9c50596adb8bbebab9d6c5c9dea7 (patch)
tree00b87b15c218039f73fcb5218281ff320c8a0632
parentfe1d4bff956d957a6ad2dcd03b15533ec03bf9d6 (diff)
task-085: can make Text italic
-rw-r--r--schist_desktop_gui/src/gui/components/text.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/schist_desktop_gui/src/gui/components/text.rs b/schist_desktop_gui/src/gui/components/text.rs
index 1760f4c..0cf9698 100644
--- a/schist_desktop_gui/src/gui/components/text.rs
+++ b/schist_desktop_gui/src/gui/components/text.rs
@@ -1,6 +1,6 @@
use std::borrow::Borrow;
-use iced::widget::container;
+use iced::{font, widget::container, Font};
use crate::{impl_focusable, style::*};
@@ -9,6 +9,7 @@ pub struct Text {
pub content: String,
align: Alignment,
colour: Option<Colour>,
+ font_style: font::Style,
overflow_strategy: OverflowStrategy,
size: Option<Size>,
strength: Option<Strength>,
@@ -54,6 +55,7 @@ impl Text {
align: Alignment::Left,
content: String::from(content),
colour: Some(Colour::Primary),
+ font_style: font::Style::Normal,
overflow_strategy: OverflowStrategy::Grow,
size: Some(Size::Base),
strength: Some(Strength::Base),
@@ -67,6 +69,7 @@ impl Text {
align: Alignment::Left,
content: String::from(content),
colour: None,
+ font_style: font::Style::Normal,
overflow_strategy: OverflowStrategy::Grow,
size: None,
strength: None,
@@ -150,6 +153,13 @@ impl Text {
..self.clone()
}
}
+
+ pub fn italic(&self) -> Self {
+ Self {
+ font_style: font::Style::Italic,
+ ..self.clone()
+ }
+ }
}
impl<'a, Message> From<Text> for iced::Element<'a, Message>
@@ -178,6 +188,10 @@ where
let overflow_strategy = &text.borrow().overflow_strategy.clone();
let text_elem: iced::widget::Text = iced::widget::text(text.borrow().content.clone())
+ .font(Font {
+ style: text.borrow().font_style,
+ ..Default::default()
+ })
.size(match text.borrow().size {
Some(Size::VSmall) => u32::from(TEXT_SIZE_V_SM),
Some(Size::Small) => u32::from(TEXT_SIZE_SM),