#[derive(Debug, Clone, PartialEq)]
pub struct TextSpec {
pub text: String,
pub font_size: f32,
pub font_weight: u16,
pub color: String,
pub max_width: f32,
pub line_height: f32,
pub tracking_em: f32,
}
impl Default for TextSpec {
fn default() -> Self {
Self {
text: "Words appear one after another in sequence".to_owned(),
font_size: 64.0,
font_weight: 700,
color: "#e6edf3".to_owned(),
max_width: 900.0,
line_height: 1.25,
tracking_em: -0.02,
}
}
}
impl TextSpec {
pub fn word_count(&self) -> usize {
self.text.split_whitespace().count()
}
pub fn line_step(&self) -> f32 {
self.font_size * self.line_height
}
}