use std::collections::HashMap;
use opentype::truetype::q32;
use crate::Number;
pub type Axes = HashMap<Type, Value>;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum Type {
Italic,
OpticalSize,
Slant,
Weight,
Width,
}
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Value {
pub default: Number,
pub range: Option<(Number, Number)>,
}
impl Value {
#[inline]
pub fn from_weight_class(value: u16) -> Self {
(value as Number).into()
}
#[inline]
pub fn from_width_class(value: u16) -> Self {
(value as Number).into()
}
pub fn from_italic_angle(value: q32) -> Self {
Number::from(value).into()
}
pub fn from_italic_flag(value: bool) -> Self {
if value {
1.0.into()
} else {
0.0.into()
}
}
}
impl From<Number> for Value {
#[inline]
fn from(default: Number) -> Self {
Self {
default,
..Default::default()
}
}
}