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
use {FontHeader, MaximumProfile, Result, Tape, Walue};
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum GlyphMapping {
HalfOffsets(Vec<u16>),
Offsets(Vec<u32>),
}
impl<'l> Walue<(&'l FontHeader, &'l MaximumProfile)> for GlyphMapping {
fn read<T: Tape>(tape: &mut T, (header, profile): (&FontHeader, &MaximumProfile))
-> Result<Self> {
let glyph_count = profile.glyph_count();
match header.glyph_mapping_format {
0 => Ok(GlyphMapping::HalfOffsets(try!(tape.take_given(glyph_count + 1)))),
1 => Ok(GlyphMapping::Offsets(try!(tape.take_given(glyph_count + 1)))),
_ => raise!("the glyph-to-location format is unknown"),
}
}
}