use crate::value::GroupValue;
#[derive(Debug, Clone, Copy)]
pub struct Style<'a> {
pub name: &'a [u8],
pub flags: i16,
pub height: f64,
pub width_factor: f64,
pub oblique_angle: f64,
pub text_generation_flags: i16,
pub primary_font_file: &'a [u8],
pub big_font_file: &'a [u8],
}
impl<'a> Default for Style<'a> {
fn default() -> Self {
Self {
name: b"",
flags: 0,
height: 0.0,
width_factor: 1.0,
oblique_angle: 0.0,
text_generation_flags: 0,
primary_font_file: b"",
big_font_file: b"",
}
}
}
impl<'a> Style<'a> {
pub(crate) fn feed(&mut self, code: u16, val: &GroupValue<'a>) {
match code {
2 => {
if let Some(v) = val.as_str_bytes() {
self.name = v;
}
}
3 => {
if let Some(v) = val.as_str_bytes() {
self.primary_font_file = v;
}
}
4 => {
if let Some(v) = val.as_str_bytes() {
self.big_font_file = v;
}
}
70 => {
if let Some(v) = val.as_i16() {
self.flags = v;
}
}
71 => {
if let Some(v) = val.as_i16() {
self.text_generation_flags = v;
}
}
_ => {
if let Some(v) = val.as_f64() {
match code {
40 => self.height = v,
41 => self.width_factor = v,
50 => self.oblique_angle = v,
_ => {}
}
}
}
}
}
}