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
//! Horizontal header table.
use crate::parse_prelude::*;
/// Tag for the `hhea` table.
pub const HHEA: Tag = Tag::new(b"hhea");
/// Horizontal header table.
///
/// <https://docs.microsoft.com/en-us/typography/opentype/spec/hhea>
#[derive(Copy, Clone)]
pub struct Hhea<'a>(Buffer<'a>);
impl<'a> Hhea<'a> {
/// Creates a new horizontal header table from a byte slice containing the
/// table data.
pub fn new(data: &'a [u8]) -> Self {
Self(Buffer::new(data))
}
/// Returns the major version.
pub fn major_version(&self) -> u16 {
self.0.read(0).unwrap_or(0)
}
/// Returns the minor version.
pub fn minor_version(&self) -> u16 {
self.0.read(2).unwrap_or(0)
}
/// Returns the typographic ascender.
pub fn ascender(&self) -> FWord {
self.0.read(4).unwrap_or(0)
}
/// Returns the typographic descender.
pub fn descender(&self) -> FWord {
self.0.read(6).unwrap_or(0)
}
/// Returns the typographic line gap.
pub fn line_gap(&self) -> FWord {
self.0.read(8).unwrap_or(0)
}
/// Returns the maximum advance width.
pub fn max_advance(&self) -> UfWord {
self.0.read(10).unwrap_or(0)
}
/// Returns the minimum left side-bearing.
pub fn min_lsb(&self) -> FWord {
self.0.read(12).unwrap_or(0)
}
/// Returns the minimum right side-bearing.
pub fn min_rsb(&self) -> FWord {
self.0.read(14).unwrap_or(0)
}
/// Returns the maximum extent: max(lsb + (x_max - x_min))
pub fn max_extent(&self) -> FWord {
self.0.read(16).unwrap_or(0)
}
/// Returns the numerator for the suggested slope of the caret.
pub fn caret_rise(&self) -> i16 {
self.0.read(18).unwrap_or(0)
}
/// Returns the denominator for the suggested slope of the caret.
pub fn caret_run(&self) -> i16 {
self.0.read(20).unwrap_or(0)
}
/// Returns the amount by which a slanted highlight on a glyph should be
/// shifted.
pub fn caret_offset(&self) -> i16 {
self.0.read(22).unwrap_or(0)
}
/// Unused in current format. Set to 0.
pub fn metric_data_format(&self) -> i16 {
self.0.read(32).unwrap_or(0)
}
/// Returns the number of "long" metric entries in the horizonal metrics
/// table.
pub fn num_long_metrics(&self) -> u16 {
self.0.read(34).unwrap_or(0)
}
}