write-fonts 0.5.0

Writing font files.
Documentation
// THIS FILE IS AUTOGENERATED.
// Any changes to this file will be overwritten.
// For more information about how codegen works, see font-codegen/README.md

#[allow(unused_imports)]
use crate::codegen_prelude::*;

/// [Compact Font Format](https://learn.microsoft.com/en-us/typography/opentype/spec/cff) table
#[derive(Clone, Debug, Default)]
pub struct Cff {
    /// Header size (bytes).
    pub hdr_size: u8,
    /// Absolute offset size.
    pub off_size: u8,
    /// Padding bytes before the start of the Name INDEX.
    pub _padding: Vec<u8>,
    /// Remaining table data.
    pub trailing_data: Vec<u8>,
}

impl Cff {
    /// Construct a new `Cff`
    pub fn new(hdr_size: u8, off_size: u8, _padding: Vec<u8>, trailing_data: Vec<u8>) -> Self {
        Self {
            hdr_size,
            off_size,
            _padding: _padding.into_iter().map(Into::into).collect(),
            trailing_data: trailing_data.into_iter().map(Into::into).collect(),
        }
    }
}

impl FontWrite for Cff {
    #[allow(clippy::unnecessary_cast)]
    fn write_into(&self, writer: &mut TableWriter) {
        (1 as u8).write_into(writer);
        (0 as u8).write_into(writer);
        self.hdr_size.write_into(writer);
        self.off_size.write_into(writer);
        self._padding.write_into(writer);
        self.trailing_data.write_into(writer);
    }
    fn table_type(&self) -> TableType {
        TableType::TopLevel(Cff::TAG)
    }
}

impl Validate for Cff {
    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
}

impl TopLevelTable for Cff {
    const TAG: Tag = Tag::new(b"CFF ");
}

impl<'a> FromObjRef<read_fonts::tables::cff::Cff<'a>> for Cff {
    fn from_obj_ref(obj: &read_fonts::tables::cff::Cff<'a>, _: FontData) -> Self {
        let offset_data = obj.offset_data();
        Cff {
            hdr_size: obj.hdr_size(),
            off_size: obj.off_size(),
            _padding: obj._padding().to_owned_obj(offset_data),
            trailing_data: obj.trailing_data().to_owned_obj(offset_data),
        }
    }
}

impl<'a> FromTableRef<read_fonts::tables::cff::Cff<'a>> for Cff {}

impl<'a> FontRead<'a> for Cff {
    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
        <read_fonts::tables::cff::Cff as FontRead>::read(data).map(|x| x.to_owned_table())
    }
}