read_fonts/generated/
generated_ebdt.rs

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)]
6use crate::codegen_prelude::*;
7
8/// The [Embedded Bitmap Data](https://learn.microsoft.com/en-us/typography/opentype/spec/ebdt) table
9#[derive(Debug, Clone, Copy)]
10#[doc(hidden)]
11pub struct EbdtMarker {}
12
13impl EbdtMarker {
14    pub fn major_version_byte_range(&self) -> Range<usize> {
15        let start = 0;
16        start..start + u16::RAW_BYTE_LEN
17    }
18
19    pub fn minor_version_byte_range(&self) -> Range<usize> {
20        let start = self.major_version_byte_range().end;
21        start..start + u16::RAW_BYTE_LEN
22    }
23}
24
25impl MinByteRange for EbdtMarker {
26    fn min_byte_range(&self) -> Range<usize> {
27        0..self.minor_version_byte_range().end
28    }
29}
30
31impl TopLevelTable for Ebdt<'_> {
32    /// `EBDT`
33    const TAG: Tag = Tag::new(b"EBDT");
34}
35
36impl<'a> FontRead<'a> for Ebdt<'a> {
37    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
38        let mut cursor = data.cursor();
39        cursor.advance::<u16>();
40        cursor.advance::<u16>();
41        cursor.finish(EbdtMarker {})
42    }
43}
44
45/// The [Embedded Bitmap Data](https://learn.microsoft.com/en-us/typography/opentype/spec/ebdt) table
46pub type Ebdt<'a> = TableRef<'a, EbdtMarker>;
47
48#[allow(clippy::needless_lifetimes)]
49impl<'a> Ebdt<'a> {
50    /// Major version of the EBDT table, = 2.
51    pub fn major_version(&self) -> u16 {
52        let range = self.shape.major_version_byte_range();
53        self.data.read_at(range.start).unwrap()
54    }
55
56    /// Minor version of EBDT table, = 0.
57    pub fn minor_version(&self) -> u16 {
58        let range = self.shape.minor_version_byte_range();
59        self.data.read_at(range.start).unwrap()
60    }
61}
62
63#[cfg(feature = "experimental_traverse")]
64impl<'a> SomeTable<'a> for Ebdt<'a> {
65    fn type_name(&self) -> &str {
66        "Ebdt"
67    }
68    fn get_field(&self, idx: usize) -> Option<Field<'a>> {
69        match idx {
70            0usize => Some(Field::new("major_version", self.major_version())),
71            1usize => Some(Field::new("minor_version", self.minor_version())),
72            _ => None,
73        }
74    }
75}
76
77#[cfg(feature = "experimental_traverse")]
78#[allow(clippy::needless_lifetimes)]
79impl<'a> std::fmt::Debug for Ebdt<'a> {
80    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
81        (self as &dyn SomeTable<'a>).fmt(f)
82    }
83}