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
use {Result, Tape, Value, q32};
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum MaximumProfile {
Version05(MaximumProfile05),
Version10(MaximumProfile10),
}
table! {
#[doc = "A maximum profile of version 0.5."]
#[derive(Copy)]
pub MaximumProfile05 {
version (q32),
glyph_count (u16),
}
}
table! {
#[doc = "A maximum profile of version 1.0."]
#[derive(Copy)]
pub MaximumProfile10 {
version (q32),
glyph_count (u16),
max_points (u16),
max_contours (u16),
max_composite_points (u16),
max_composite_contours (u16),
max_zones (u16),
max_twilight_points (u16),
max_storage (u16),
max_function_definitions (u16),
max_instruction_definitions (u16),
max_stack_elements (u16),
max_size_of_instructions (u16),
max_component_elements (u16),
max_component_depth (u16),
}
}
impl MaximumProfile {
pub fn glyph_count(&self) -> usize {
match self {
&MaximumProfile::Version05(ref profile) => profile.glyph_count as usize,
&MaximumProfile::Version10(ref profile) => profile.glyph_count as usize,
}
}
}
impl Value for MaximumProfile {
fn read<T: Tape>(tape: &mut T) -> Result<Self> {
Ok(match try!(tape.peek::<q32>()) {
q32(0x00005000) => MaximumProfile::Version05(try!(tape.take())),
q32(0x00010000) => MaximumProfile::Version10(try!(tape.take())),
_ => raise!("found an unknown version of the maximum profile"),
})
}
}