Coverage Report

Created: 2026-04-01 07:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/fontations/read-fonts/generated/generated_ebdt.rs
Line
Count
Source
1
// THIS FILE IS AUTOGENERATED.
2
// Any changes to this file will be overwritten.
3
// For more information about how codegen works, see font-codegen/README.md
4
5
#[allow(unused_imports)]
6
use crate::codegen_prelude::*;
7
8
impl<'a> MinByteRange<'a> for Ebdt<'a> {
9
0
    fn min_byte_range(&self) -> Range<usize> {
10
0
        0..self.minor_version_byte_range().end
11
0
    }
12
0
    fn min_table_bytes(&self) -> &'a [u8] {
13
0
        let range = self.min_byte_range();
14
0
        self.data.as_bytes().get(range).unwrap_or_default()
15
0
    }
16
}
17
18
impl TopLevelTable for Ebdt<'_> {
19
    /// `EBDT`
20
    const TAG: Tag = Tag::new(b"EBDT");
21
}
22
23
impl<'a> FontRead<'a> for Ebdt<'a> {
24
0
    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
25
        #[allow(clippy::absurd_extreme_comparisons)]
26
0
        if data.len() < Self::MIN_SIZE {
27
0
            return Err(ReadError::OutOfBounds);
28
0
        }
29
0
        Ok(Self { data })
30
0
    }
31
}
32
33
/// The [Embedded Bitmap Data](https://learn.microsoft.com/en-us/typography/opentype/spec/ebdt) table
34
#[derive(Clone)]
35
pub struct Ebdt<'a> {
36
    data: FontData<'a>,
37
}
38
39
#[allow(clippy::needless_lifetimes)]
40
impl<'a> Ebdt<'a> {
41
    pub const MIN_SIZE: usize = (u16::RAW_BYTE_LEN + u16::RAW_BYTE_LEN);
42
    basic_table_impls!(impl_the_methods);
43
44
    /// Major version of the EBDT table, = 2.
45
0
    pub fn major_version(&self) -> u16 {
46
0
        let range = self.major_version_byte_range();
47
0
        self.data.read_at(range.start).ok().unwrap()
48
0
    }
49
50
    /// Minor version of EBDT table, = 0.
51
0
    pub fn minor_version(&self) -> u16 {
52
0
        let range = self.minor_version_byte_range();
53
0
        self.data.read_at(range.start).ok().unwrap()
54
0
    }
55
56
0
    pub fn major_version_byte_range(&self) -> Range<usize> {
57
0
        let start = 0;
58
0
        start..start + u16::RAW_BYTE_LEN
59
0
    }
60
61
0
    pub fn minor_version_byte_range(&self) -> Range<usize> {
62
0
        let start = self.major_version_byte_range().end;
63
0
        start..start + u16::RAW_BYTE_LEN
64
0
    }
65
}
66
67
#[cfg(feature = "experimental_traverse")]
68
impl<'a> SomeTable<'a> for Ebdt<'a> {
69
    fn type_name(&self) -> &str {
70
        "Ebdt"
71
    }
72
    fn get_field(&self, idx: usize) -> Option<Field<'a>> {
73
        match idx {
74
            0usize => Some(Field::new("major_version", self.major_version())),
75
            1usize => Some(Field::new("minor_version", self.minor_version())),
76
            _ => None,
77
        }
78
    }
79
}
80
81
#[cfg(feature = "experimental_traverse")]
82
#[allow(clippy::needless_lifetimes)]
83
impl<'a> std::fmt::Debug for Ebdt<'a> {
84
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
85
        (self as &dyn SomeTable<'a>).fmt(f)
86
    }
87
}