Coverage Report

Created: 2026-10-24 07:19

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/read-fonts-0.46.0/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.offset_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 ReadArgs for Ebdt<'_> {
24
    type Args = ();
25
}
26
27
impl<'a> FontRead<'a> for Ebdt<'a> {
28
0
    fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
29
        #[allow(clippy::absurd_extreme_comparisons)]
30
0
        if data.len() < Self::MIN_SIZE {
31
0
            return Err(ReadError::OutOfBounds);
32
0
        }
33
0
        let Some(data) = TableDataRef::new(data.as_bytes()) else {
34
0
            return Err(ReadError::OutOfBounds);
35
        };
36
0
        Ok(Self { data })
37
0
    }
38
}
39
40
/// The fields at the start of the table, which are read directly.
41
#[derive(Clone, Copy, bytemuck :: AnyBitPattern)]
42
#[repr(C, packed)]
43
#[doc(hidden)]
44
pub struct EbdtFixedHeader {
45
    pub major_version: BigEndian<u16>,
46
    pub minor_version: BigEndian<u16>,
47
}
48
49
#[allow(clippy::absurd_extreme_comparisons)]
50
const _: () = assert!(std::mem::size_of::<EbdtFixedHeader>() <= Ebdt::MIN_SIZE);
51
52
/// The [Embedded Bitmap Data](https://learn.microsoft.com/en-us/typography/opentype/spec/ebdt) table
53
#[derive(Clone)]
54
pub struct Ebdt<'a> {
55
    data: TableDataRef<'a, EbdtFixedHeader>,
56
}
57
58
#[allow(clippy::needless_lifetimes)]
59
impl<'a> Ebdt<'a> {
60
    pub const MIN_SIZE: usize = (u16::RAW_BYTE_LEN + u16::RAW_BYTE_LEN);
61
    basic_table_impls!(impl_the_methods);
62
63
    /// Major version of the EBDT table, = 2.
64
0
    pub fn major_version(&self) -> u16 {
65
0
        self.data.header().major_version.get()
66
0
    }
67
68
    /// Minor version of EBDT table, = 0.
69
0
    pub fn minor_version(&self) -> u16 {
70
0
        self.data.header().minor_version.get()
71
0
    }
72
73
0
    pub fn major_version_byte_range(&self) -> Range<usize> {
74
0
        let start = 0;
75
0
        let end = start + u16::RAW_BYTE_LEN;
76
0
        start..end
77
0
    }
78
79
0
    pub fn minor_version_byte_range(&self) -> Range<usize> {
80
0
        let start = self.major_version_byte_range().end;
81
0
        let end = start + u16::RAW_BYTE_LEN;
82
0
        start..end
83
0
    }
84
}
85
86
const _: () = assert!(FontData::default_data_long_enough(Ebdt::MIN_SIZE));
87
88
impl Default for Ebdt<'_> {
89
0
    fn default() -> Self {
90
        Self {
91
0
            data: TableDataRef::new(FontData::default_table_data().as_bytes())
92
0
                .unwrap_or_else(|| unreachable!("the default data covers MIN_SIZE")),
93
        }
94
0
    }
95
}