write_fonts/generated/
generated_head.rs1#[allow(unused_imports)]
6use crate::codegen_prelude::*;
7
8pub use read_fonts::tables::head::MacStyle;
9
10impl FontWrite for MacStyle {
11 fn write_into(&self, writer: &mut TableWriter) {
12 writer.write_slice(&self.bits().to_be_bytes())
13 }
14}
15
16#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
19#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
20pub struct Head {
21 pub font_revision: Fixed,
23 pub checksum_adjustment: u32,
29 pub magic_number: u32,
31 pub flags: u16,
33 pub units_per_em: u16,
38 pub created: LongDateTime,
41 pub modified: LongDateTime,
44 pub x_min: i16,
46 pub y_min: i16,
48 pub x_max: i16,
50 pub y_max: i16,
52 pub mac_style: MacStyle,
54 pub lowest_rec_ppem: u16,
56 pub font_direction_hint: i16,
58 pub index_to_loc_format: i16,
60}
61
62impl Default for Head {
63 fn default() -> Self {
64 Self {
65 font_revision: Default::default(),
66 checksum_adjustment: Default::default(),
67 magic_number: 0x5F0F3CF5,
68 flags: Default::default(),
69 units_per_em: Default::default(),
70 created: Default::default(),
71 modified: Default::default(),
72 x_min: Default::default(),
73 y_min: Default::default(),
74 x_max: Default::default(),
75 y_max: Default::default(),
76 mac_style: Default::default(),
77 lowest_rec_ppem: Default::default(),
78 font_direction_hint: 2,
79 index_to_loc_format: Default::default(),
80 }
81 }
82}
83
84impl Head {
85 #[allow(clippy::too_many_arguments)]
87 pub fn new(
88 font_revision: Fixed,
89 checksum_adjustment: u32,
90 flags: u16,
91 units_per_em: u16,
92 created: LongDateTime,
93 modified: LongDateTime,
94 x_min: i16,
95 y_min: i16,
96 x_max: i16,
97 y_max: i16,
98 mac_style: MacStyle,
99 lowest_rec_ppem: u16,
100 index_to_loc_format: i16,
101 ) -> Self {
102 Self {
103 font_revision,
104 checksum_adjustment,
105 flags,
106 units_per_em,
107 created,
108 modified,
109 x_min,
110 y_min,
111 x_max,
112 y_max,
113 mac_style,
114 lowest_rec_ppem,
115 index_to_loc_format,
116 ..Default::default()
117 }
118 }
119}
120
121impl FontWrite for Head {
122 #[allow(clippy::unnecessary_cast)]
123 fn write_into(&self, writer: &mut TableWriter) {
124 (MajorMinor::VERSION_1_0 as MajorMinor).write_into(writer);
125 self.font_revision.write_into(writer);
126 self.checksum_adjustment.write_into(writer);
127 self.magic_number.write_into(writer);
128 self.flags.write_into(writer);
129 self.units_per_em.write_into(writer);
130 self.created.write_into(writer);
131 self.modified.write_into(writer);
132 self.x_min.write_into(writer);
133 self.y_min.write_into(writer);
134 self.x_max.write_into(writer);
135 self.y_max.write_into(writer);
136 self.mac_style.write_into(writer);
137 self.lowest_rec_ppem.write_into(writer);
138 self.font_direction_hint.write_into(writer);
139 self.index_to_loc_format.write_into(writer);
140 (0 as i16).write_into(writer);
141 }
142 fn table_type(&self) -> TableType {
143 TableType::TopLevel(Head::TAG)
144 }
145}
146
147impl Validate for Head {
148 fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
149}
150
151impl TopLevelTable for Head {
152 const TAG: Tag = Tag::new(b"head");
153}
154
155impl<'a> FromObjRef<read_fonts::tables::head::Head<'a>> for Head {
156 fn from_obj_ref(obj: &read_fonts::tables::head::Head<'a>, _: FontData) -> Self {
157 Head {
158 font_revision: obj.font_revision(),
159 checksum_adjustment: obj.checksum_adjustment(),
160 magic_number: obj.magic_number(),
161 flags: obj.flags(),
162 units_per_em: obj.units_per_em(),
163 created: obj.created(),
164 modified: obj.modified(),
165 x_min: obj.x_min(),
166 y_min: obj.y_min(),
167 x_max: obj.x_max(),
168 y_max: obj.y_max(),
169 mac_style: obj.mac_style(),
170 lowest_rec_ppem: obj.lowest_rec_ppem(),
171 font_direction_hint: obj.font_direction_hint(),
172 index_to_loc_format: obj.index_to_loc_format(),
173 }
174 }
175}
176
177#[allow(clippy::needless_lifetimes)]
178impl<'a> FromTableRef<read_fonts::tables::head::Head<'a>> for Head {}
179
180impl<'a> FontRead<'a> for Head {
181 fn read(data: FontData<'a>) -> Result<Self, ReadError> {
182 <read_fonts::tables::head::Head as FontRead>::read(data).map(|x| x.to_owned_table())
183 }
184}