/src/fontations/write-fonts/generated/generated_hvar.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 [HVAR (Horizontal Metrics Variations)](https://docs.microsoft.com/en-us/typography/opentype/spec/hvar) table |
9 | | #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] |
10 | | #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] |
11 | | pub struct Hvar { |
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 widths (may be NULL). |
15 | | pub advance_width_mapping: NullableOffsetMarker<DeltaSetIndexMap, WIDTH_32>, |
16 | | /// Offset in bytes from the start of this table to the delta-set index mapping for left side bearings (may be NULL). |
17 | | pub lsb_mapping: NullableOffsetMarker<DeltaSetIndexMap, WIDTH_32>, |
18 | | /// Offset in bytes from the start of this table to the delta-set index mapping for right side bearings (may be NULL). |
19 | | pub rsb_mapping: NullableOffsetMarker<DeltaSetIndexMap, WIDTH_32>, |
20 | | } |
21 | | |
22 | | impl Hvar { |
23 | | /// Construct a new `Hvar` |
24 | 0 | pub fn new( |
25 | 0 | item_variation_store: ItemVariationStore, |
26 | 0 | advance_width_mapping: Option<DeltaSetIndexMap>, |
27 | 0 | lsb_mapping: Option<DeltaSetIndexMap>, |
28 | 0 | rsb_mapping: Option<DeltaSetIndexMap>, |
29 | 0 | ) -> Self { |
30 | 0 | Self { |
31 | 0 | item_variation_store: item_variation_store.into(), |
32 | 0 | advance_width_mapping: advance_width_mapping.into(), |
33 | 0 | lsb_mapping: lsb_mapping.into(), |
34 | 0 | rsb_mapping: rsb_mapping.into(), |
35 | 0 | } |
36 | 0 | } |
37 | | } |
38 | | |
39 | | impl FontWrite for Hvar { |
40 | | #[allow(clippy::unnecessary_cast)] |
41 | 0 | fn write_into(&self, writer: &mut TableWriter) { |
42 | 0 | (MajorMinor::VERSION_1_0 as MajorMinor).write_into(writer); |
43 | 0 | self.item_variation_store.write_into(writer); |
44 | 0 | self.advance_width_mapping.write_into(writer); |
45 | 0 | self.lsb_mapping.write_into(writer); |
46 | 0 | self.rsb_mapping.write_into(writer); |
47 | 0 | } |
48 | 0 | fn table_type(&self) -> TableType { |
49 | 0 | TableType::TopLevel(Hvar::TAG) |
50 | 0 | } |
51 | | } |
52 | | |
53 | | impl Validate for Hvar { |
54 | 0 | fn validate_impl(&self, ctx: &mut ValidationCtx) { |
55 | 0 | ctx.in_table("Hvar", |ctx| { |
56 | 0 | ctx.in_field("item_variation_store", |ctx| { |
57 | 0 | self.item_variation_store.validate_impl(ctx); |
58 | 0 | }); |
59 | 0 | ctx.in_field("advance_width_mapping", |ctx| { |
60 | 0 | self.advance_width_mapping.validate_impl(ctx); |
61 | 0 | }); |
62 | 0 | ctx.in_field("lsb_mapping", |ctx| { |
63 | 0 | self.lsb_mapping.validate_impl(ctx); |
64 | 0 | }); |
65 | 0 | ctx.in_field("rsb_mapping", |ctx| { |
66 | 0 | self.rsb_mapping.validate_impl(ctx); |
67 | 0 | }); |
68 | 0 | }) |
69 | 0 | } |
70 | | } |
71 | | |
72 | | impl TopLevelTable for Hvar { |
73 | | const TAG: Tag = Tag::new(b"HVAR"); |
74 | | } |
75 | | |
76 | | impl<'a> FromObjRef<read_fonts::tables::hvar::Hvar<'a>> for Hvar { |
77 | 0 | fn from_obj_ref(obj: &read_fonts::tables::hvar::Hvar<'a>, _: FontData) -> Self { |
78 | 0 | Hvar { |
79 | 0 | item_variation_store: obj.item_variation_store().to_owned_table(), |
80 | 0 | advance_width_mapping: obj.advance_width_mapping().to_owned_table(), |
81 | 0 | lsb_mapping: obj.lsb_mapping().to_owned_table(), |
82 | 0 | rsb_mapping: obj.rsb_mapping().to_owned_table(), |
83 | 0 | } |
84 | 0 | } |
85 | | } |
86 | | |
87 | | #[allow(clippy::needless_lifetimes)] |
88 | | impl<'a> FromTableRef<read_fonts::tables::hvar::Hvar<'a>> for Hvar {} |
89 | | |
90 | | impl ReadArgs for Hvar { |
91 | | type Args = (); |
92 | | } |
93 | | |
94 | | impl<'a> FontRead<'a> for Hvar { |
95 | 0 | fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> { |
96 | 0 | <read_fonts::tables::hvar::Hvar as FontRead>::read(data).map(|x| x.to_owned_table()) |
97 | 0 | } |
98 | | } |