read_fonts/generated/
generated_ebdt.rs1#[allow(unused_imports)]
6use crate::codegen_prelude::*;
7
8impl<'a> MinByteRange<'a> for Ebdt<'a> {
9 fn min_byte_range(&self) -> Range<usize> {
10 0..self.minor_version_byte_range().end
11 }
12 fn min_table_bytes(&self) -> &'a [u8] {
13 let range = self.min_byte_range();
14 self.offset_data().as_bytes().get(range).unwrap_or_default()
15 }
16}
17
18impl TopLevelTable for Ebdt<'_> {
19 const TAG: Tag = Tag::new(b"EBDT");
21}
22
23impl ReadArgs for Ebdt<'_> {
24 type Args = ();
25}
26
27impl<'a> FontRead<'a> for Ebdt<'a> {
28 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
29 #[allow(clippy::absurd_extreme_comparisons)]
30 if data.len() < Self::MIN_SIZE {
31 return Err(ReadError::OutOfBounds);
32 }
33 let Some(data) = TableDataRef::new(data.as_bytes()) else {
34 return Err(ReadError::OutOfBounds);
35 };
36 Ok(Self { data })
37 }
38}
39
40#[derive(Clone, Copy, bytemuck :: AnyBitPattern)]
42#[repr(C, packed)]
43#[doc(hidden)]
44pub struct EbdtFixedHeader {
45 pub major_version: BigEndian<u16>,
46 pub minor_version: BigEndian<u16>,
47}
48
49#[allow(clippy::absurd_extreme_comparisons)]
50const _: () = assert!(std::mem::size_of::<EbdtFixedHeader>() <= Ebdt::MIN_SIZE);
51
52#[derive(Clone)]
54pub struct Ebdt<'a> {
55 data: TableDataRef<'a, EbdtFixedHeader>,
56}
57
58#[allow(clippy::needless_lifetimes)]
59impl<'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 pub fn major_version(&self) -> u16 {
65 self.data.header().major_version.get()
66 }
67
68 pub fn minor_version(&self) -> u16 {
70 self.data.header().minor_version.get()
71 }
72
73 pub fn major_version_byte_range(&self) -> Range<usize> {
74 let start = 0;
75 let end = start + u16::RAW_BYTE_LEN;
76 start..end
77 }
78
79 pub fn minor_version_byte_range(&self) -> Range<usize> {
80 let start = self.major_version_byte_range().end;
81 let end = start + u16::RAW_BYTE_LEN;
82 start..end
83 }
84}
85
86const _: () = assert!(FontData::default_data_long_enough(Ebdt::MIN_SIZE));
87
88impl Default for Ebdt<'_> {
89 fn default() -> Self {
90 Self {
91 data: TableDataRef::new(FontData::default_table_data().as_bytes())
92 .unwrap_or_else(|| unreachable!("the default data covers MIN_SIZE")),
93 }
94 }
95}