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() > (u16::MAX as usize) {
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<'a> FontRead<'a> for Mvar {
77 fn read(data: FontData<'a>) -> Result<Self, ReadError> {
78 <read_fonts::tables::mvar::Mvar as FontRead>::read(data).map(|x| x.to_owned_table())
79 }
80}
81
82#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
84#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
85pub struct ValueRecord {
86 pub value_tag: Tag,
88 pub delta_set_outer_index: u16,
90 pub delta_set_inner_index: u16,
92}
93
94impl ValueRecord {
95 pub fn new(value_tag: Tag, delta_set_outer_index: u16, delta_set_inner_index: u16) -> Self {
97 Self {
98 value_tag,
99 delta_set_outer_index,
100 delta_set_inner_index,
101 }
102 }
103}
104
105impl FontWrite for ValueRecord {
106 fn write_into(&self, writer: &mut TableWriter) {
107 self.value_tag.write_into(writer);
108 self.delta_set_outer_index.write_into(writer);
109 self.delta_set_inner_index.write_into(writer);
110 }
111 fn table_type(&self) -> TableType {
112 TableType::Named("ValueRecord")
113 }
114}
115
116impl Validate for ValueRecord {
117 fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
118}
119
120impl FromObjRef<read_fonts::tables::mvar::ValueRecord> for ValueRecord {
121 fn from_obj_ref(obj: &read_fonts::tables::mvar::ValueRecord, _: FontData) -> Self {
122 ValueRecord {
123 value_tag: obj.value_tag(),
124 delta_set_outer_index: obj.delta_set_outer_index(),
125 delta_set_inner_index: obj.delta_set_inner_index(),
126 }
127 }
128}