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 /// The [VVAR (Vertical Metrics Variations)](https://docs.microsoft.com/en-us/typography/opentype/spec/vvar) table 9 #[derive(Debug, Clone, Copy)] 10 #[doc(hidden)] 11 pub struct VvarMarker {} 12 13 impl VvarMarker { version_byte_range(&self) -> Range<usize>14 fn version_byte_range(&self) -> Range<usize> { 15 let start = 0; 16 start..start + MajorMinor::RAW_BYTE_LEN 17 } item_variation_store_offset_byte_range(&self) -> Range<usize>18 fn item_variation_store_offset_byte_range(&self) -> Range<usize> { 19 let start = self.version_byte_range().end; 20 start..start + Offset32::RAW_BYTE_LEN 21 } advance_height_mapping_offset_byte_range(&self) -> Range<usize>22 fn advance_height_mapping_offset_byte_range(&self) -> Range<usize> { 23 let start = self.item_variation_store_offset_byte_range().end; 24 start..start + Offset32::RAW_BYTE_LEN 25 } tsb_mapping_offset_byte_range(&self) -> Range<usize>26 fn tsb_mapping_offset_byte_range(&self) -> Range<usize> { 27 let start = self.advance_height_mapping_offset_byte_range().end; 28 start..start + Offset32::RAW_BYTE_LEN 29 } bsb_mapping_offset_byte_range(&self) -> Range<usize>30 fn bsb_mapping_offset_byte_range(&self) -> Range<usize> { 31 let start = self.tsb_mapping_offset_byte_range().end; 32 start..start + Offset32::RAW_BYTE_LEN 33 } v_org_mapping_offset_byte_range(&self) -> Range<usize>34 fn v_org_mapping_offset_byte_range(&self) -> Range<usize> { 35 let start = self.bsb_mapping_offset_byte_range().end; 36 start..start + Offset32::RAW_BYTE_LEN 37 } 38 } 39 40 impl TopLevelTable for Vvar<'_> { 41 /// `VVAR` 42 const TAG: Tag = Tag::new(b"VVAR"); 43 } 44 45 impl<'a> FontRead<'a> for Vvar<'a> { read(data: FontData<'a>) -> Result<Self, ReadError>46 fn read(data: FontData<'a>) -> Result<Self, ReadError> { 47 let mut cursor = data.cursor(); 48 cursor.advance::<MajorMinor>(); 49 cursor.advance::<Offset32>(); 50 cursor.advance::<Offset32>(); 51 cursor.advance::<Offset32>(); 52 cursor.advance::<Offset32>(); 53 cursor.advance::<Offset32>(); 54 cursor.finish(VvarMarker {}) 55 } 56 } 57 58 /// The [VVAR (Vertical Metrics Variations)](https://docs.microsoft.com/en-us/typography/opentype/spec/vvar) table 59 pub type Vvar<'a> = TableRef<'a, VvarMarker>; 60 61 impl<'a> Vvar<'a> { 62 /// Major version number of the horizontal metrics variations table — set to 1. 63 /// Minor version number of the horizontal metrics variations table — set to 0. version(&self) -> MajorMinor64 pub fn version(&self) -> MajorMinor { 65 let range = self.shape.version_byte_range(); 66 self.data.read_at(range.start).unwrap() 67 } 68 69 /// Offset in bytes from the start of this table to the item variation store table. item_variation_store_offset(&self) -> Offset3270 pub fn item_variation_store_offset(&self) -> Offset32 { 71 let range = self.shape.item_variation_store_offset_byte_range(); 72 self.data.read_at(range.start).unwrap() 73 } 74 75 /// Attempt to resolve [`item_variation_store_offset`][Self::item_variation_store_offset]. item_variation_store(&self) -> Result<ItemVariationStore<'a>, ReadError>76 pub fn item_variation_store(&self) -> Result<ItemVariationStore<'a>, ReadError> { 77 let data = self.data; 78 self.item_variation_store_offset().resolve(data) 79 } 80 81 /// Offset in bytes from the start of this table to the delta-set index mapping for advance heights (may be NULL). advance_height_mapping_offset(&self) -> Nullable<Offset32>82 pub fn advance_height_mapping_offset(&self) -> Nullable<Offset32> { 83 let range = self.shape.advance_height_mapping_offset_byte_range(); 84 self.data.read_at(range.start).unwrap() 85 } 86 87 /// Attempt to resolve [`advance_height_mapping_offset`][Self::advance_height_mapping_offset]. advance_height_mapping(&self) -> Option<Result<DeltaSetIndexMap<'a>, ReadError>>88 pub fn advance_height_mapping(&self) -> Option<Result<DeltaSetIndexMap<'a>, ReadError>> { 89 let data = self.data; 90 self.advance_height_mapping_offset().resolve(data) 91 } 92 93 /// Offset in bytes from the start of this table to the delta-set index mapping for top side bearings (may be NULL). tsb_mapping_offset(&self) -> Nullable<Offset32>94 pub fn tsb_mapping_offset(&self) -> Nullable<Offset32> { 95 let range = self.shape.tsb_mapping_offset_byte_range(); 96 self.data.read_at(range.start).unwrap() 97 } 98 99 /// Attempt to resolve [`tsb_mapping_offset`][Self::tsb_mapping_offset]. tsb_mapping(&self) -> Option<Result<DeltaSetIndexMap<'a>, ReadError>>100 pub fn tsb_mapping(&self) -> Option<Result<DeltaSetIndexMap<'a>, ReadError>> { 101 let data = self.data; 102 self.tsb_mapping_offset().resolve(data) 103 } 104 105 /// Offset in bytes from the start of this table to the delta-set index mapping for bottom side bearings (may be NULL). bsb_mapping_offset(&self) -> Nullable<Offset32>106 pub fn bsb_mapping_offset(&self) -> Nullable<Offset32> { 107 let range = self.shape.bsb_mapping_offset_byte_range(); 108 self.data.read_at(range.start).unwrap() 109 } 110 111 /// Attempt to resolve [`bsb_mapping_offset`][Self::bsb_mapping_offset]. bsb_mapping(&self) -> Option<Result<DeltaSetIndexMap<'a>, ReadError>>112 pub fn bsb_mapping(&self) -> Option<Result<DeltaSetIndexMap<'a>, ReadError>> { 113 let data = self.data; 114 self.bsb_mapping_offset().resolve(data) 115 } 116 117 /// Offset in bytes from the start of this table to the delta-set index mapping for Y coordinates of vertical origins (may be NULL). v_org_mapping_offset(&self) -> Nullable<Offset32>118 pub fn v_org_mapping_offset(&self) -> Nullable<Offset32> { 119 let range = self.shape.v_org_mapping_offset_byte_range(); 120 self.data.read_at(range.start).unwrap() 121 } 122 123 /// Attempt to resolve [`v_org_mapping_offset`][Self::v_org_mapping_offset]. v_org_mapping(&self) -> Option<Result<DeltaSetIndexMap<'a>, ReadError>>124 pub fn v_org_mapping(&self) -> Option<Result<DeltaSetIndexMap<'a>, ReadError>> { 125 let data = self.data; 126 self.v_org_mapping_offset().resolve(data) 127 } 128 } 129 130 #[cfg(feature = "traversal")] 131 impl<'a> SomeTable<'a> for Vvar<'a> { type_name(&self) -> &str132 fn type_name(&self) -> &str { 133 "Vvar" 134 } get_field(&self, idx: usize) -> Option<Field<'a>>135 fn get_field(&self, idx: usize) -> Option<Field<'a>> { 136 match idx { 137 0usize => Some(Field::new("version", self.version())), 138 1usize => Some(Field::new( 139 "item_variation_store_offset", 140 FieldType::offset( 141 self.item_variation_store_offset(), 142 self.item_variation_store(), 143 ), 144 )), 145 2usize => Some(Field::new( 146 "advance_height_mapping_offset", 147 FieldType::offset( 148 self.advance_height_mapping_offset(), 149 self.advance_height_mapping(), 150 ), 151 )), 152 3usize => Some(Field::new( 153 "tsb_mapping_offset", 154 FieldType::offset(self.tsb_mapping_offset(), self.tsb_mapping()), 155 )), 156 4usize => Some(Field::new( 157 "bsb_mapping_offset", 158 FieldType::offset(self.bsb_mapping_offset(), self.bsb_mapping()), 159 )), 160 5usize => Some(Field::new( 161 "v_org_mapping_offset", 162 FieldType::offset(self.v_org_mapping_offset(), self.v_org_mapping()), 163 )), 164 _ => None, 165 } 166 } 167 } 168 169 #[cfg(feature = "traversal")] 170 impl<'a> std::fmt::Debug for Vvar<'a> { fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result171 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 172 (self as &dyn SomeTable<'a>).fmt(f) 173 } 174 } 175