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
//! The [gasp](https://learn.microsoft.com/en-us/typography/opentype/spec/gasp) table

include!("../../generated/generated_gasp.rs");

#[cfg(test)]
mod tests {
    use super::*;
    use crate::test_helpers::BeBuffer;

    #[test]
    fn smoke_test() {
        let buf = BeBuffer::new()
            .push(1u16) // version
            .push(2u16) // number of records
            .push(404u16) // record 1 ppem
            .push(GaspRangeBehavior::GASP_GRIDFIT | GaspRangeBehavior::GASP_DOGRAY)
            .push(u16::MAX)
            .push(
                GaspRangeBehavior::GASP_SYMMETRIC_GRIDFIT
                    | GaspRangeBehavior::GASP_SYMMETRIC_SMOOTHING,
            );

        let gasp = Gasp::read(buf.font_data()).unwrap();
        assert_eq!(gasp.version(), 1);
        assert_eq!(
            gasp.gasp_ranges()[0],
            GaspRange {
                range_max_ppem: 404.into(),
                range_gasp_behavior: (GaspRangeBehavior::GASP_GRIDFIT
                    | GaspRangeBehavior::GASP_DOGRAY)
                    .into(),
            }
        );
        assert_eq!(
            gasp.gasp_ranges()[1],
            GaspRange {
                range_max_ppem: u16::MAX.into(),
                range_gasp_behavior: (GaspRangeBehavior::GASP_SYMMETRIC_GRIDFIT
                    | GaspRangeBehavior::GASP_SYMMETRIC_SMOOTHING)
                    .into(),
            }
        );
    }
}