write_fonts/generated/
generated_mvar.rs1#[allow(unused_imports)]
6use crate::codegen_prelude::*;
7
8#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
10#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11pub struct Mvar {
12 pub version: MajorMinor,
15 pub value_record_size: u16,
17 pub value_record_count: u16,
19 pub item_variation_store: NullableOffsetMarker<ItemVariationStore>,
21 pub value_records: Vec<ValueRecord>,
23}
24
25impl FontWrite for Mvar {
26 #[allow(clippy::unnecessary_cast)]
27 fn write_into(&self, writer: &mut TableWriter) {
28 self.version.write_into(writer);
29 (0 as u16).write_into(writer);
30 self.value_record_size.write_into(writer);
31 self.value_record_count.write_into(writer);
32 self.item_variation_store.write_into(writer);
33 self.value_records.write_into(writer);
34 }
35 fn table_type(&self) -> TableType {
36 TableType::TopLevel(Mvar::TAG)
37 }
38}
39
40impl Validate for Mvar {
41 fn validate_impl(&self, ctx: &mut ValidationCtx) {
42 ctx.in_table("Mvar", |ctx| {
43 ctx.in_field("item_variation_store", |ctx| {
44 self.item_variation_store.validate_impl(ctx);
45 });
46 ctx.in_field("value_records", |ctx| {
47 if self.value_records.len() > to_usize(u16::MAX) {
48 ctx.report("array exceeds max length");
49 }
50 self.value_records.validate_impl(ctx);
51 });
52 })
53 }
54}
55
56impl TopLevelTable for Mvar {
57 const TAG: Tag = Tag::new(b"MVAR");
58}
59
60impl<'a> FromObjRef<read_fonts::tables::mvar::Mvar<'a>> for Mvar {
61 fn from_obj_ref(obj: &read_fonts::tables::mvar::Mvar<'a>, _: FontData) -> Self {
62 let offset_data = obj.offset_data();
63 Mvar {
64 version: obj.version(),
65 value_record_size: obj.value_record_size(),
66 value_record_count: obj.value_record_count(),
67 item_variation_store: obj.item_variation_store().to_owned_table(),
68 value_records: obj.value_records().to_owned_obj(offset_data),
69 }
70 }
71}
72
73#[allow(clippy::needless_lifetimes)]
74impl<'a> FromTableRef<read_fonts::tables::mvar::Mvar<'a>> for Mvar {}
75
76impl ReadArgs for Mvar {
77 type Args = ();
78}
79
80impl<'a> FontRead<'a> for Mvar {
81 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
82 <read_fonts::tables::mvar::Mvar as FontRead>::read(data).map(|x| x.to_owned_table())
83 }
84}
85
86#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
88#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
89pub struct ValueRecord {
90 pub value_tag: Tag,
92 pub delta_set_outer_index: u16,
94 pub delta_set_inner_index: u16,
96}
97
98impl ValueRecord {
99 pub fn new(value_tag: Tag, delta_set_outer_index: u16, delta_set_inner_index: u16) -> Self {
101 Self {
102 value_tag,
103 delta_set_outer_index,
104 delta_set_inner_index,
105 }
106 }
107}
108
109impl FontWrite for ValueRecord {
110 fn write_into(&self, writer: &mut TableWriter) {
111 self.value_tag.write_into(writer);
112 self.delta_set_outer_index.write_into(writer);
113 self.delta_set_inner_index.write_into(writer);
114 }
115 fn table_type(&self) -> TableType {
116 TableType::Named("ValueRecord")
117 }
118}
119
120impl Validate for ValueRecord {
121 fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
122}
123
124impl FromObjRef<read_fonts::tables::mvar::ValueRecord> for ValueRecord {
125 fn from_obj_ref(obj: &read_fonts::tables::mvar::ValueRecord, _: FontData) -> Self {
126 ValueRecord {
127 value_tag: obj.value_tag(),
128 delta_set_outer_index: obj.delta_set_outer_index(),
129 delta_set_inner_index: obj.delta_set_inner_index(),
130 }
131 }
132}