#[allow(unused_imports)]
use crate::codegen_prelude::*;
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Mvar {
pub version: MajorMinor,
pub value_record_size: u16,
pub value_record_count: u16,
pub item_variation_store: NullableOffsetMarker<ItemVariationStore>,
pub value_records: Vec<ValueRecord>,
}
impl FontWrite for Mvar {
#[allow(clippy::unnecessary_cast)]
fn write_into(&self, writer: &mut TableWriter) {
self.version.write_into(writer);
(0 as u16).write_into(writer);
self.value_record_size.write_into(writer);
self.value_record_count.write_into(writer);
self.item_variation_store.write_into(writer);
self.value_records.write_into(writer);
}
fn table_type(&self) -> TableType {
TableType::TopLevel(Mvar::TAG)
}
}
impl Validate for Mvar {
fn validate_impl(&self, ctx: &mut ValidationCtx) {
ctx.in_table("Mvar", |ctx| {
ctx.in_field("item_variation_store", |ctx| {
self.item_variation_store.validate_impl(ctx);
});
ctx.in_field("value_records", |ctx| {
if self.value_records.len() > (u16::MAX as usize) {
ctx.report("array exceeds max length");
}
self.value_records.validate_impl(ctx);
});
})
}
}
impl TopLevelTable for Mvar {
const TAG: Tag = Tag::new(b"MVAR");
}
impl<'a> FromObjRef<read_fonts::tables::mvar::Mvar<'a>> for Mvar {
fn from_obj_ref(obj: &read_fonts::tables::mvar::Mvar<'a>, _: FontData) -> Self {
let offset_data = obj.offset_data();
Mvar {
version: obj.version(),
value_record_size: obj.value_record_size(),
value_record_count: obj.value_record_count(),
item_variation_store: obj.item_variation_store().to_owned_table(),
value_records: obj.value_records().to_owned_obj(offset_data),
}
}
}
impl<'a> FromTableRef<read_fonts::tables::mvar::Mvar<'a>> for Mvar {}
impl<'a> FontRead<'a> for Mvar {
fn read(data: FontData<'a>) -> Result<Self, ReadError> {
<read_fonts::tables::mvar::Mvar as FontRead>::read(data).map(|x| x.to_owned_table())
}
}
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ValueRecord {
pub value_tag: Tag,
pub delta_set_outer_index: u16,
pub delta_set_inner_index: u16,
}
impl ValueRecord {
pub fn new(value_tag: Tag, delta_set_outer_index: u16, delta_set_inner_index: u16) -> Self {
Self {
value_tag,
delta_set_outer_index,
delta_set_inner_index,
}
}
}
impl FontWrite for ValueRecord {
fn write_into(&self, writer: &mut TableWriter) {
self.value_tag.write_into(writer);
self.delta_set_outer_index.write_into(writer);
self.delta_set_inner_index.write_into(writer);
}
fn table_type(&self) -> TableType {
TableType::Named("ValueRecord")
}
}
impl Validate for ValueRecord {
fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
}
impl FromObjRef<read_fonts::tables::mvar::ValueRecord> for ValueRecord {
fn from_obj_ref(obj: &read_fonts::tables::mvar::ValueRecord, _: FontData) -> Self {
ValueRecord {
value_tag: obj.value_tag(),
delta_set_outer_index: obj.delta_set_outer_index(),
delta_set_inner_index: obj.delta_set_inner_index(),
}
}
}