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
//! Maximum profile table.
use crate::parse_prelude::*;
/// Tag for the `maxp` table.
pub const MAXP: Tag = Tag::new(b"maxp");
/// Maximum profile table.
///
/// <https://docs.microsoft.com/en-us/typography/opentype/spec/maxp>
#[derive(Copy, Clone)]
pub struct Maxp<'a>(Buffer<'a>);
impl<'a> Maxp<'a> {
/// Creates a new maximum profile table from a byte slice containing the
/// table data.
pub fn new(data: &'a [u8]) -> Self {
Self(Buffer::new(data))
}
/// Returns the version of the table.
/// - 0x00005000: Version 0.5 - only `num_glyphs` will return a meaningful value.
/// - 0x00010000: Version 1.0
pub fn version(&self) -> Fixed {
self.0.read(0).unwrap_or(Fixed::ZERO)
}
/// Returns the number of glyphs in the font.
pub fn num_glyphs(&self) -> u16 {
self.0.read(4).unwrap_or(0)
}
/// Returns the maximum points in a simple glyph.
pub fn max_points(&self) -> u16 {
self.0.read(6).unwrap_or(0)
}
/// Returns the maximum contours in a simple glyph.
pub fn max_contours(&self) -> u16 {
self.0.read(8).unwrap_or(0)
}
/// Returns the maximum points in a composite glyph.
pub fn max_composite_points(&self) -> u16 {
self.0.read(10).unwrap_or(0)
}
/// Returns the maximum contours in a composite glyph.
pub fn max_composite_contours(&self) -> u16 {
self.0.read(12).unwrap_or(0)
}
/// Returns 2 if instructions require a 'twilight zone' or 1 otherwise.
pub fn max_zones(&self) -> u16 {
self.0.read(14).unwrap_or(0)
}
/// Returns the maximum twilight points used in zone 0.
pub fn max_twilight_points(&self) -> u16 {
self.0.read(16).unwrap_or(0)
}
/// Returns the maximum storage area locations.
pub fn max_storage(&self) -> u16 {
self.0.read(18).unwrap_or(0)
}
/// Returns the maximum function definitions.
pub fn max_function_defs(&self) -> u16 {
self.0.read(20).unwrap_or(0)
}
/// Returns the maximum instruction definitions.
pub fn max_instruction_defs(&self) -> u16 {
self.0.read(22).unwrap_or(0)
}
/// Returns the maximum stack depth across all programs in the font.
pub fn max_stack_depth(&self) -> u16 {
self.0.read(24).unwrap_or(0)
}
/// Returns the maximum size of glyph instructions.
pub fn max_instructions_size(&self) -> u16 {
self.0.read(26).unwrap_or(0)
}
/// Returns the maximum number of components for a single composite glyph.
pub fn max_component_elements(&self) -> u16 {
self.0.read(28).unwrap_or(0)
}
/// Returns the maximum nesting level for any composite glyph.
pub fn max_component_depth(&self) -> u16 {
self.0.read(30).unwrap_or(0)
}
}