1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#[allow(unused_imports)]
use crate::codegen_prelude::*;
#[derive(Clone, Debug)]
pub struct Head {
pub font_revision: Fixed,
pub checksum_adjustment: u32,
pub magic_number: u32,
pub flags: u16,
pub units_per_em: u16,
pub created: LongDateTime,
pub modified: LongDateTime,
pub x_min: i16,
pub y_min: i16,
pub x_max: i16,
pub y_max: i16,
pub mac_style: u16,
pub lowest_rec_ppem: u16,
pub font_direction_hint: i16,
pub index_to_loc_format: i16,
}
impl Default for Head {
fn default() -> Self {
Self {
font_revision: Default::default(),
checksum_adjustment: Default::default(),
magic_number: 0x5F0F3CF5,
flags: Default::default(),
units_per_em: Default::default(),
created: Default::default(),
modified: Default::default(),
x_min: Default::default(),
y_min: Default::default(),
x_max: Default::default(),
y_max: Default::default(),
mac_style: Default::default(),
lowest_rec_ppem: Default::default(),
font_direction_hint: 2,
index_to_loc_format: Default::default(),
}
}
}
impl Head {
#[allow(clippy::too_many_arguments)]
pub fn new(
font_revision: Fixed,
checksum_adjustment: u32,
flags: u16,
units_per_em: u16,
created: LongDateTime,
modified: LongDateTime,
x_min: i16,
y_min: i16,
x_max: i16,
y_max: i16,
mac_style: u16,
lowest_rec_ppem: u16,
index_to_loc_format: i16,
) -> Self {
Self {
font_revision,
checksum_adjustment,
flags,
units_per_em,
created,
modified,
x_min,
y_min,
x_max,
y_max,
mac_style,
lowest_rec_ppem,
index_to_loc_format,
..Default::default()
}
}
}
impl FontWrite for Head {
#[allow(clippy::unnecessary_cast)]
fn write_into(&self, writer: &mut TableWriter) {
(MajorMinor::VERSION_1_0 as MajorMinor).write_into(writer);
self.font_revision.write_into(writer);
self.checksum_adjustment.write_into(writer);
self.magic_number.write_into(writer);
self.flags.write_into(writer);
self.units_per_em.write_into(writer);
self.created.write_into(writer);
self.modified.write_into(writer);
self.x_min.write_into(writer);
self.y_min.write_into(writer);
self.x_max.write_into(writer);
self.y_max.write_into(writer);
self.mac_style.write_into(writer);
self.lowest_rec_ppem.write_into(writer);
self.font_direction_hint.write_into(writer);
self.index_to_loc_format.write_into(writer);
(0 as i16).write_into(writer);
}
}
impl Validate for Head {
fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
}
impl TopLevelTable for Head {
const TAG: Tag = Tag::new(b"head");
}
impl<'a> FromObjRef<read_fonts::tables::head::Head<'a>> for Head {
fn from_obj_ref(obj: &read_fonts::tables::head::Head<'a>, _: FontData) -> Self {
Head {
font_revision: obj.font_revision(),
checksum_adjustment: obj.checksum_adjustment(),
magic_number: obj.magic_number(),
flags: obj.flags(),
units_per_em: obj.units_per_em(),
created: obj.created(),
modified: obj.modified(),
x_min: obj.x_min(),
y_min: obj.y_min(),
x_max: obj.x_max(),
y_max: obj.y_max(),
mac_style: obj.mac_style(),
lowest_rec_ppem: obj.lowest_rec_ppem(),
font_direction_hint: obj.font_direction_hint(),
index_to_loc_format: obj.index_to_loc_format(),
}
}
}
impl<'a> FromTableRef<read_fonts::tables::head::Head<'a>> for Head {}
impl<'a> FontRead<'a> for Head {
fn read(data: FontData<'a>) -> Result<Self, ReadError> {
<read_fonts::tables::head::Head as FontRead>::read(data).map(|x| x.to_owned_table())
}
}