Skip to main content

read_fonts/tables/
maxp.rs

1//! The [maxp](https://docs.microsoft.com/en-us/typography/opentype/spec/maxp) table
2
3include!("../../generated/generated_maxp.rs");
4
5/// A maximum profile from MAXP or the original maxp table.
6#[derive(Clone)]
7pub enum SelectedMaxp<'a> {
8    /// The original `maxp` table.
9    Original(Maxp<'a>),
10    /// The `MAXP` table (ISO/IEC 14496-22:2026).
11    Extended(MaxpExtended<'a>),
12}
13
14impl SelectedMaxp<'_> {
15    /// Returns the glyph count without narrowing it to 16 bits.
16    pub fn num_glyphs(&self) -> u32 {
17        match self {
18            Self::Original(table) => table.num_glyphs().into(),
19            Self::Extended(table) => table.num_glyphs().into(),
20        }
21    }
22
23    selected_table_getters!(
24        version -> Version16Dot16,
25        max_points -> Option<u16>,
26        max_contours -> Option<u16>,
27        max_composite_points -> Option<u16>,
28        max_composite_contours -> Option<u16>,
29        max_zones -> Option<u16>,
30        max_twilight_points -> Option<u16>,
31        max_storage -> Option<u16>,
32        max_function_defs -> Option<u16>,
33        max_instruction_defs -> Option<u16>,
34        max_stack_elements -> Option<u16>,
35        max_size_of_instructions -> Option<u16>,
36        max_component_elements -> Option<u16>,
37        max_component_depth -> Option<u16>,
38    );
39}