#[allow(unused_imports)]
use crate::codegen_prelude::*;
#[derive(Debug, Clone, Copy)]
#[doc(hidden)]
pub struct VvarMarker {}
impl VvarMarker {
fn version_byte_range(&self) -> Range<usize> {
let start = 0;
start..start + MajorMinor::RAW_BYTE_LEN
}
fn item_variation_store_offset_byte_range(&self) -> Range<usize> {
let start = self.version_byte_range().end;
start..start + Offset32::RAW_BYTE_LEN
}
fn advance_height_mapping_offset_byte_range(&self) -> Range<usize> {
let start = self.item_variation_store_offset_byte_range().end;
start..start + Offset32::RAW_BYTE_LEN
}
fn tsb_mapping_offset_byte_range(&self) -> Range<usize> {
let start = self.advance_height_mapping_offset_byte_range().end;
start..start + Offset32::RAW_BYTE_LEN
}
fn bsb_mapping_offset_byte_range(&self) -> Range<usize> {
let start = self.tsb_mapping_offset_byte_range().end;
start..start + Offset32::RAW_BYTE_LEN
}
fn v_org_mapping_offset_byte_range(&self) -> Range<usize> {
let start = self.bsb_mapping_offset_byte_range().end;
start..start + Offset32::RAW_BYTE_LEN
}
}
impl TopLevelTable for Vvar<'_> {
const TAG: Tag = Tag::new(b"VVAR");
}
impl<'a> FontRead<'a> for Vvar<'a> {
fn read(data: FontData<'a>) -> Result<Self, ReadError> {
let mut cursor = data.cursor();
cursor.advance::<MajorMinor>();
cursor.advance::<Offset32>();
cursor.advance::<Offset32>();
cursor.advance::<Offset32>();
cursor.advance::<Offset32>();
cursor.advance::<Offset32>();
cursor.finish(VvarMarker {})
}
}
pub type Vvar<'a> = TableRef<'a, VvarMarker>;
impl<'a> Vvar<'a> {
pub fn version(&self) -> MajorMinor {
let range = self.shape.version_byte_range();
self.data.read_at(range.start).unwrap()
}
pub fn item_variation_store_offset(&self) -> Offset32 {
let range = self.shape.item_variation_store_offset_byte_range();
self.data.read_at(range.start).unwrap()
}
pub fn item_variation_store(&self) -> Result<ItemVariationStore<'a>, ReadError> {
let data = self.data;
self.item_variation_store_offset().resolve(data)
}
pub fn advance_height_mapping_offset(&self) -> Nullable<Offset32> {
let range = self.shape.advance_height_mapping_offset_byte_range();
self.data.read_at(range.start).unwrap()
}
pub fn advance_height_mapping(&self) -> Option<Result<DeltaSetIndexMap<'a>, ReadError>> {
let data = self.data;
self.advance_height_mapping_offset().resolve(data)
}
pub fn tsb_mapping_offset(&self) -> Nullable<Offset32> {
let range = self.shape.tsb_mapping_offset_byte_range();
self.data.read_at(range.start).unwrap()
}
pub fn tsb_mapping(&self) -> Option<Result<DeltaSetIndexMap<'a>, ReadError>> {
let data = self.data;
self.tsb_mapping_offset().resolve(data)
}
pub fn bsb_mapping_offset(&self) -> Nullable<Offset32> {
let range = self.shape.bsb_mapping_offset_byte_range();
self.data.read_at(range.start).unwrap()
}
pub fn bsb_mapping(&self) -> Option<Result<DeltaSetIndexMap<'a>, ReadError>> {
let data = self.data;
self.bsb_mapping_offset().resolve(data)
}
pub fn v_org_mapping_offset(&self) -> Nullable<Offset32> {
let range = self.shape.v_org_mapping_offset_byte_range();
self.data.read_at(range.start).unwrap()
}
pub fn v_org_mapping(&self) -> Option<Result<DeltaSetIndexMap<'a>, ReadError>> {
let data = self.data;
self.v_org_mapping_offset().resolve(data)
}
}
#[cfg(feature = "experimental_traverse")]
impl<'a> SomeTable<'a> for Vvar<'a> {
fn type_name(&self) -> &str {
"Vvar"
}
fn get_field(&self, idx: usize) -> Option<Field<'a>> {
match idx {
0usize => Some(Field::new("version", self.version())),
1usize => Some(Field::new(
"item_variation_store_offset",
FieldType::offset(
self.item_variation_store_offset(),
self.item_variation_store(),
),
)),
2usize => Some(Field::new(
"advance_height_mapping_offset",
FieldType::offset(
self.advance_height_mapping_offset(),
self.advance_height_mapping(),
),
)),
3usize => Some(Field::new(
"tsb_mapping_offset",
FieldType::offset(self.tsb_mapping_offset(), self.tsb_mapping()),
)),
4usize => Some(Field::new(
"bsb_mapping_offset",
FieldType::offset(self.bsb_mapping_offset(), self.bsb_mapping()),
)),
5usize => Some(Field::new(
"v_org_mapping_offset",
FieldType::offset(self.v_org_mapping_offset(), self.v_org_mapping()),
)),
_ => None,
}
}
}
#[cfg(feature = "experimental_traverse")]
impl<'a> std::fmt::Debug for Vvar<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
(self as &dyn SomeTable<'a>).fmt(f)
}
}