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
//! The feature list.

use truetype::Tag;

table! {
    @position
    #[doc = "A feature list."]
    pub Features {
        count (u16), // FeatureCount

        headers (Vec<Header>) |this, tape, _| { // FeatureRecord
            tape.take_given(this.count as usize)
        },

        records (Vec<Record>) |this, tape, position| {
            jump_take!(tape, position, this.count, i => this.headers[i].offset)
        },
    }
}

table! {
    #[doc = "A feature header."]
    #[derive(Copy)]
    pub Header {
        tag    (Tag), // FeatureTag
        offset (u16), // Feature
    }
}

table! {
    @position
    #[doc = "A feature record."]
    pub Record {
        parameter_offset (u16), // FeatureParams
        lookup_count     (u16), // LookupCount

        lookup_indices (Vec<u16>) |this, tape, _| { // LookupListIndex
            tape.take_given(this.lookup_count as usize)
        },

        parameters (Option<Vec<u8>>) |this, tape, position| {
            if this.parameter_offset != 0 {
                try!(tape.jump(position + this.parameter_offset as u64));
                Ok(Some(try!(tape.take_bytes(0))))
            } else {
                Ok(None)
            }
        },
    }
}