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
use crate::number::q32;
use crate::{Result, Tape, Value};
#[derive(Clone, Debug)]
pub enum MaximumProfile {
Version0(MaximumProfile0),
Version1(MaximumProfile1),
}
table! {
#[doc = "A maximum profile of version 0.5."]
#[derive(Copy)]
pub MaximumProfile0 {
version (q32), glyph_count (u16), }
}
table! {
#[doc = "A maximum profile of version 1."]
#[derive(Copy)]
pub MaximumProfile1 {
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::Version0(ref profile) => profile.glyph_count as usize,
&MaximumProfile::Version1(ref profile) => profile.glyph_count as usize,
}
}
}
impl Value for MaximumProfile {
fn read<T: Tape>(tape: &mut T) -> Result<Self> {
Ok(match tape.peek::<q32>()? {
q32(0x00005000) => MaximumProfile::Version0(tape.take()?),
q32(0x00010000) => MaximumProfile::Version1(tape.take()?),
_ => raise!("found an unknown version of the maximum profile"),
})
}
}