use std::{ fmt::Display, hash::{Hash, Hasher}, }; use colors_transform::Rgb; use iced::{ font::{Style, Weight}, widget::{container, svg::Handle, Svg}, Element, Length, Size, }; use tracing::error; use crate::TextAlignment; #[derive(Clone, Debug, Default, PartialEq)] pub struct TextSvg { text: String, font: Font, shadow: Option, stroke: Option, fill: Color, alignment: TextAlignment, handle: Option, } impl Hash for TextSvg { fn hash(&self, state: &mut H) { self.text.hash(state); self.font.hash(state); self.shadow.hash(state); self.stroke.hash(state); self.fill.hash(state); self.alignment.hash(state); } } #[derive(Clone, Debug, Default, PartialEq, Eq, Hash)] pub struct Font { name: String, weight: Weight, style: Style, size: u8, } impl From for Font { fn from(value: iced::font::Font) -> Self { Self { name: match value.family { iced::font::Family::Name(name) => name.to_string(), _ => "Quicksand Bold".into(), }, size: 20, ..Default::default() } } } impl From for Font { fn from(value: String) -> Self { Self { name: value, ..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 } pub fn get_style(&self) -> Style { self.style } pub fn weight(mut self, weight: impl Into) -> Self { self.weight = weight.into(); self } pub fn style(mut self, style: impl Into