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
use crate::parser::Stream;
#[derive(Clone, Copy, Default, Debug)]
pub struct Table {
pub ascender: i16,
pub descender: i16,
pub line_gap: i16,
pub number_of_metrics: u16,
}
impl Table {
pub fn parse(data: &[u8]) -> Option<Self> {
if data.len() != 36 {
return None
}
let mut s = Stream::new(data);
s.skip::<u32>();
let ascender = s.read::<i16>()?;
let descender = s.read::<i16>()?;
let line_gap = s.read::<i16>()?;
s.advance(24);
let number_of_metrics = s.read::<u16>()?;
Some(Table {
ascender,
descender,
line_gap,
number_of_metrics,
})
}
}