use std::fmt::Display; use colors_transform::Rgb; use cosmic::{ iced::{ font::{Style, Weight}, Length, }, prelude::*, widget::{container, responsive, svg::Handle, Svg}, }; use tracing::{debug, error}; use crate::TextAlignment; #[derive(Clone, Debug, Default, PartialEq)] pub struct TextSvg { text: String, font: Font, shadow: Option, stroke: Option, fill: Color, alignment: TextAlignment, } #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct Font { name: String, weight: Weight, style: Style, size: u8, } impl From for Font { fn from(value: cosmic::font::Font) -> Self { Self { name: match value.family { cosmic::iced::font::Family::Name(name) => { name.to_string() } _ => "Quicksand Bold".into(), }, size: 20, ..Default::default() } } } impl From<&str> for Font { fn from(value: &str) -> Self { Self { name: value.to_owned(), ..Default::default() } } } impl Font { pub fn get_name(&self) -> String { self.name.clone() } pub fn get_weight(&self) -> Weight { self.weight.clone() } pub fn get_style(&self) -> Style { self.style.clone() } pub fn weight(mut self, weight: impl Into) -> Self { self.weight = weight.into(); self } pub fn style(mut self, style: impl Into