x-graphics 0.2.1

Graphics framework for X
Documentation
use crate::{
    font::{FontStyle, FontWeight},
    Float,
};

pub(super) fn gen_font_string(font_family: &str, font_size: Float, font_style: FontStyle, font_weight: FontWeight) -> String {
    let font_style: &str = font_style.into();
    let font_weight: &str = font_weight.into();
    format!("{} {} {}px {}", font_style, font_weight, font_size, font_family)
}
impl From<FontStyle> for &'static str {
    fn from(font_style: FontStyle) -> Self {
        match font_style {
            FontStyle::Italic => "italic",
            _ => "",
        }
    }
}

impl From<FontWeight> for &'static str {
    fn from(font_weight: FontWeight) -> Self {
        match font_weight {
            FontWeight::Thin => "100",
            FontWeight::ExtraLight => "200",
            FontWeight::Light => "300",
            FontWeight::Normal => "normal",
            FontWeight::Medium => "500",
            FontWeight::SemiBold => "600",
            FontWeight::Bold => "bold",
            FontWeight::ExtraBold => "800",
            FontWeight::Black => "900",
            FontWeight::ExtraBlack => "950",
        }
    }
}