truetype/tables/
maximum_profile.rs1use crate::{q32, Result};
6
7#[derive(Clone, Debug)]
9pub enum MaximumProfile {
10 Version0(MaximumProfile0),
12 Version1(MaximumProfile1),
14}
15
16table! {
17 #[derive(Copy)]
19 pub MaximumProfile0 {
20 version (q32), glyph_count (u16), }
23}
24
25table! {
26 #[derive(Copy)]
28 pub MaximumProfile1 {
29 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), }
45}
46
47impl MaximumProfile {
48 pub fn glyph_count(&self) -> usize {
50 match self {
51 MaximumProfile::Version0(ref profile) => profile.glyph_count as usize,
52 MaximumProfile::Version1(ref profile) => profile.glyph_count as usize,
53 }
54 }
55}
56
57impl crate::value::Read for MaximumProfile {
58 fn read<T: crate::tape::Read>(tape: &mut T) -> Result<Self> {
59 Ok(match tape.peek::<q32>()? {
60 q32(0x00005000) => MaximumProfile::Version0(tape.take()?),
61 q32(0x00010000) => MaximumProfile::Version1(tape.take()?),
62 _ => raise!("found an unknown version of the maximum profile"),
63 })
64 }
65}