/src/fontations/write-fonts/generated/generated_vvar.rs
Line | Count | Source |
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(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] |
10 | | #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] |
11 | | pub struct Vvar { |
12 | | /// Offset in bytes from the start of this table to the item variation store table. |
13 | | pub item_variation_store: OffsetMarker<ItemVariationStore, WIDTH_32>, |
14 | | /// Offset in bytes from the start of this table to the delta-set index mapping for advance heights (may be NULL). |
15 | | pub advance_height_mapping: NullableOffsetMarker<DeltaSetIndexMap, WIDTH_32>, |
16 | | /// Offset in bytes from the start of this table to the delta-set index mapping for top side bearings (may be NULL). |
17 | | pub tsb_mapping: NullableOffsetMarker<DeltaSetIndexMap, WIDTH_32>, |
18 | | /// Offset in bytes from the start of this table to the delta-set index mapping for bottom side bearings (may be NULL). |
19 | | pub bsb_mapping: NullableOffsetMarker<DeltaSetIndexMap, WIDTH_32>, |
20 | | /// Offset in bytes from the start of this table to the delta-set index mapping for Y coordinates of vertical origins (may be NULL). |
21 | | pub v_org_mapping: NullableOffsetMarker<DeltaSetIndexMap, WIDTH_32>, |
22 | | } |
23 | | |
24 | | impl Vvar { |
25 | | /// Construct a new `Vvar` |
26 | 0 | pub fn new( |
27 | 0 | item_variation_store: ItemVariationStore, |
28 | 0 | advance_height_mapping: Option<DeltaSetIndexMap>, |
29 | 0 | tsb_mapping: Option<DeltaSetIndexMap>, |
30 | 0 | bsb_mapping: Option<DeltaSetIndexMap>, |
31 | 0 | v_org_mapping: Option<DeltaSetIndexMap>, |
32 | 0 | ) -> Self { |
33 | 0 | Self { |
34 | 0 | item_variation_store: item_variation_store.into(), |
35 | 0 | advance_height_mapping: advance_height_mapping.into(), |
36 | 0 | tsb_mapping: tsb_mapping.into(), |
37 | 0 | bsb_mapping: bsb_mapping.into(), |
38 | 0 | v_org_mapping: v_org_mapping.into(), |
39 | 0 | } |
40 | 0 | } |
41 | | } |
42 | | |
43 | | impl FontWrite for Vvar { |
44 | | #[allow(clippy::unnecessary_cast)] |
45 | 0 | fn write_into(&self, writer: &mut TableWriter) { |
46 | 0 | (MajorMinor::VERSION_1_0 as MajorMinor).write_into(writer); |
47 | 0 | self.item_variation_store.write_into(writer); |
48 | 0 | self.advance_height_mapping.write_into(writer); |
49 | 0 | self.tsb_mapping.write_into(writer); |
50 | 0 | self.bsb_mapping.write_into(writer); |
51 | 0 | self.v_org_mapping.write_into(writer); |
52 | 0 | } |
53 | 0 | fn table_type(&self) -> TableType { |
54 | 0 | TableType::TopLevel(Vvar::TAG) |
55 | 0 | } |
56 | | } |
57 | | |
58 | | impl Validate for Vvar { |
59 | 0 | fn validate_impl(&self, ctx: &mut ValidationCtx) { |
60 | 0 | ctx.in_table("Vvar", |ctx| { |
61 | 0 | ctx.in_field("item_variation_store", |ctx| { |
62 | 0 | self.item_variation_store.validate_impl(ctx); |
63 | 0 | }); |
64 | 0 | ctx.in_field("advance_height_mapping", |ctx| { |
65 | 0 | self.advance_height_mapping.validate_impl(ctx); |
66 | 0 | }); |
67 | 0 | ctx.in_field("tsb_mapping", |ctx| { |
68 | 0 | self.tsb_mapping.validate_impl(ctx); |
69 | 0 | }); |
70 | 0 | ctx.in_field("bsb_mapping", |ctx| { |
71 | 0 | self.bsb_mapping.validate_impl(ctx); |
72 | 0 | }); |
73 | 0 | ctx.in_field("v_org_mapping", |ctx| { |
74 | 0 | self.v_org_mapping.validate_impl(ctx); |
75 | 0 | }); |
76 | 0 | }) |
77 | 0 | } |
78 | | } |
79 | | |
80 | | impl TopLevelTable for Vvar { |
81 | | const TAG: Tag = Tag::new(b"VVAR"); |
82 | | } |
83 | | |
84 | | impl<'a> FromObjRef<read_fonts::tables::vvar::Vvar<'a>> for Vvar { |
85 | 0 | fn from_obj_ref(obj: &read_fonts::tables::vvar::Vvar<'a>, _: FontData) -> Self { |
86 | 0 | Vvar { |
87 | 0 | item_variation_store: obj.item_variation_store().to_owned_table(), |
88 | 0 | advance_height_mapping: obj.advance_height_mapping().to_owned_table(), |
89 | 0 | tsb_mapping: obj.tsb_mapping().to_owned_table(), |
90 | 0 | bsb_mapping: obj.bsb_mapping().to_owned_table(), |
91 | 0 | v_org_mapping: obj.v_org_mapping().to_owned_table(), |
92 | 0 | } |
93 | 0 | } |
94 | | } |
95 | | |
96 | | #[allow(clippy::needless_lifetimes)] |
97 | | impl<'a> FromTableRef<read_fonts::tables::vvar::Vvar<'a>> for Vvar {} |
98 | | |
99 | | impl ReadArgs for Vvar { |
100 | | type Args = (); |
101 | | } |
102 | | |
103 | | impl<'a> FontRead<'a> for Vvar { |
104 | 0 | fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> { |
105 | 0 | <read_fonts::tables::vvar::Vvar as FontRead>::read(data).map(|x| x.to_owned_table()) |
106 | 0 | } |
107 | | } |