use std::str::FromStr;
use strum_macros::EnumString;
use crate::geometry::Dimension;
#[derive(Copy, Clone, Debug, PartialEq, EnumString)]
pub enum FontWeight {
#[strum(disabled)]
Number(f32),
#[strum(serialize = "thin")]
Thin,
#[strum(serialize = "extra-light")]
ExtraLight,
#[strum(serialize = "light")]
Light,
#[strum(serialize = "normal")]
Normal,
#[strum(serialize = "medium")]
Medium,
#[strum(serialize = "semi-bold")]
SemiBold,
#[strum(serialize = "bold")]
Bold,
#[strum(serialize = "extra-bold")]
ExtraBold,
#[strum(serialize = "black")]
Black,
}
impl Default for FontWeight {
fn default() -> Self {
FontWeight::Normal
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, EnumString)]
pub enum GenericFontFamily {
#[strum(serialize = "serif")]
Serif,
#[strum(serialize = "sans-serif")]
SansSerif,
#[strum(serialize = "monospace")]
Monospace,
}
impl Default for GenericFontFamily {
fn default() -> Self {
GenericFontFamily::SansSerif
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum FontFamily<S = &'static str> {
Generic(GenericFontFamily),
Named(S),
}
impl<S> FromStr for FontFamily<S> {
type Err = <GenericFontFamily as FromStr>::Err;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(FontFamily::Generic(GenericFontFamily::from_str(s)?))
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, EnumString)]
pub enum FontStyle {
#[strum(serialize = "normal")]
Normal,
#[strum(serialize = "oblique")]
Oblique,
#[strum(serialize = "italic")]
Italic,
}
impl Default for FontStyle {
fn default() -> Self {
FontStyle::Normal
}
}
#[derive(Copy, Clone, Debug, PartialEq, EnumString)]
pub enum FontSize {
#[strum(serialize = "extra-extra-small")]
ExtraExtraSmall,
#[strum(serialize = "extra-small")]
ExtraSmall,
#[strum(serialize = "small")]
Small,
#[strum(serialize = "medium")]
Medium,
#[strum(serialize = "large")]
Large,
#[strum(serialize = "extra-large")]
ExtraLarge,
#[strum(serialize = "extra-extra-large")]
ExtraExtraLarge,
#[strum(serialize = "extra-extra-extra-large")]
ExtraExtraExtraLarge,
#[strum(disabled)]
Dimension(Dimension<f32>),
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Font {
pub family: FontFamily,
pub weight: FontWeight,
pub style: FontStyle,
pub size: FontSize,
}