#[allow(unused_imports)]
use crate::codegen_prelude::*;
impl<'a> MinByteRange<'a> for Cbdt<'a> {
fn min_byte_range(&self) -> Range<usize> {
0..self.minor_version_byte_range().end
}
fn min_table_bytes(&self) -> &'a [u8] {
let range = self.min_byte_range();
self.offset_data().as_bytes().get(range).unwrap_or_default()
}
}
impl TopLevelTable for Cbdt<'_> {
const TAG: Tag = Tag::new(b"CBDT");
}
impl ReadArgs for Cbdt<'_> {
type Args = ();
}
impl<'a> FontRead<'a> for Cbdt<'a> {
fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
#[allow(clippy::absurd_extreme_comparisons)]
if data.len() < Self::MIN_SIZE {
return Err(ReadError::OutOfBounds);
}
let Some(data) = TableDataRef::new(data.as_bytes()) else {
return Err(ReadError::OutOfBounds);
};
Ok(Self { data })
}
}
#[derive(Clone, Copy, bytemuck :: AnyBitPattern)]
#[repr(C, packed)]
#[doc(hidden)]
pub struct CbdtFixedHeader {
pub major_version: BigEndian<u16>,
pub minor_version: BigEndian<u16>,
}
#[allow(clippy::absurd_extreme_comparisons)]
const _: () = assert!(std::mem::size_of::<CbdtFixedHeader>() <= Cbdt::MIN_SIZE);
#[derive(Clone)]
pub struct Cbdt<'a> {
data: TableDataRef<'a, CbdtFixedHeader>,
}
#[allow(clippy::needless_lifetimes)]
impl<'a> Cbdt<'a> {
pub const MIN_SIZE: usize = (u16::RAW_BYTE_LEN + u16::RAW_BYTE_LEN);
basic_table_impls!(impl_the_methods);
pub fn major_version(&self) -> u16 {
self.data.header().major_version.get()
}
pub fn minor_version(&self) -> u16 {
self.data.header().minor_version.get()
}
pub fn major_version_byte_range(&self) -> Range<usize> {
let start = 0;
let end = start + u16::RAW_BYTE_LEN;
start..end
}
pub fn minor_version_byte_range(&self) -> Range<usize> {
let start = self.major_version_byte_range().end;
let end = start + u16::RAW_BYTE_LEN;
start..end
}
}
const _: () = assert!(FontData::default_data_long_enough(Cbdt::MIN_SIZE));
impl Default for Cbdt<'_> {
fn default() -> Self {
Self {
data: TableDataRef::new(FontData::default_table_data().as_bytes())
.unwrap_or_else(|| unreachable!("the default data covers MIN_SIZE")),
}
}
}