Skip to main content

write_fonts/generated/
generated_vhea.rs

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)]
6use crate::codegen_prelude::*;
7
8/// The [vhea](https://docs.microsoft.com/en-us/typography/opentype/spec/vhea) Vertical Header Table
9#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
10#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11pub struct Vhea {
12    /// The major/minor version (1, 0 or 1, 1)
13    pub version: Version16Dot16,
14    /// Typographic ascent.
15    pub ascender: FWord,
16    /// Typographic descent.
17    pub descender: FWord,
18    /// Typographic line gap. Negative LineGap values are treated as
19    /// zero in some legacy platform implementations.
20    pub line_gap: FWord,
21    /// Maximum advance height value in 'vmtx' table.
22    pub advance_height_max: UfWord,
23    /// Minimum top sidebearing value in 'vmtx' table for glyphs with
24    /// contours (empty glyphs should be ignored).
25    pub min_top_side_bearing: FWord,
26    /// Minimum bottom sidebearing value
27    pub min_bottom_side_bearing: FWord,
28    /// Defined as max( tsb + (yMax-yMin)).
29    pub y_max_extent: FWord,
30    /// Used to calculate the slope of the cursor (rise/run); 1 for
31    /// vertical caret, 0 for horizontal.
32    pub caret_slope_rise: i16,
33    /// 0 for vertical caret, 1 for horizontal.
34    pub caret_slope_run: i16,
35    /// The amount by which a slanted highlight on a glyph needs to be
36    /// shifted to produce the best appearance. Set to 0 for
37    /// non-slanted fonts
38    pub caret_offset: i16,
39    /// Number of advance heights in the vertical metrics (`vmtx`) table.
40    pub number_of_long_ver_metrics: u16,
41}
42
43impl Default for Vhea {
44    fn default() -> Self {
45        Self {
46            version: Version16Dot16::VERSION_1_1,
47            ascender: Default::default(),
48            descender: Default::default(),
49            line_gap: Default::default(),
50            advance_height_max: Default::default(),
51            min_top_side_bearing: Default::default(),
52            min_bottom_side_bearing: Default::default(),
53            y_max_extent: Default::default(),
54            caret_slope_rise: Default::default(),
55            caret_slope_run: Default::default(),
56            caret_offset: Default::default(),
57            number_of_long_ver_metrics: Default::default(),
58        }
59    }
60}
61
62impl Vhea {
63    /// Construct a new `Vhea`
64    #[allow(clippy::too_many_arguments)]
65    pub fn new(
66        ascender: FWord,
67        descender: FWord,
68        line_gap: FWord,
69        advance_height_max: UfWord,
70        min_top_side_bearing: FWord,
71        min_bottom_side_bearing: FWord,
72        y_max_extent: FWord,
73        caret_slope_rise: i16,
74        caret_slope_run: i16,
75        caret_offset: i16,
76        number_of_long_ver_metrics: u16,
77    ) -> Self {
78        Self {
79            ascender,
80            descender,
81            line_gap,
82            advance_height_max,
83            min_top_side_bearing,
84            min_bottom_side_bearing,
85            y_max_extent,
86            caret_slope_rise,
87            caret_slope_run,
88            caret_offset,
89            number_of_long_ver_metrics,
90            ..Default::default()
91        }
92    }
93}
94
95impl FontWrite for Vhea {
96    #[allow(clippy::unnecessary_cast)]
97    fn write_into(&self, writer: &mut TableWriter) {
98        self.version.write_into(writer);
99        self.ascender.write_into(writer);
100        self.descender.write_into(writer);
101        self.line_gap.write_into(writer);
102        self.advance_height_max.write_into(writer);
103        self.min_top_side_bearing.write_into(writer);
104        self.min_bottom_side_bearing.write_into(writer);
105        self.y_max_extent.write_into(writer);
106        self.caret_slope_rise.write_into(writer);
107        self.caret_slope_run.write_into(writer);
108        self.caret_offset.write_into(writer);
109        (0 as i16).write_into(writer);
110        (0 as i16).write_into(writer);
111        (0 as i16).write_into(writer);
112        (0 as i16).write_into(writer);
113        (0 as i16).write_into(writer);
114        self.number_of_long_ver_metrics.write_into(writer);
115    }
116    fn table_type(&self) -> TableType {
117        TableType::TopLevel(Vhea::TAG)
118    }
119}
120
121impl Validate for Vhea {
122    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
123}
124
125impl TopLevelTable for Vhea {
126    const TAG: Tag = Tag::new(b"vhea");
127}
128
129impl<'a> FromObjRef<read_fonts::tables::vhea::Vhea<'a>> for Vhea {
130    fn from_obj_ref(obj: &read_fonts::tables::vhea::Vhea<'a>, _: FontData) -> Self {
131        Vhea {
132            version: obj.version(),
133            ascender: obj.ascender(),
134            descender: obj.descender(),
135            line_gap: obj.line_gap(),
136            advance_height_max: obj.advance_height_max(),
137            min_top_side_bearing: obj.min_top_side_bearing(),
138            min_bottom_side_bearing: obj.min_bottom_side_bearing(),
139            y_max_extent: obj.y_max_extent(),
140            caret_slope_rise: obj.caret_slope_rise(),
141            caret_slope_run: obj.caret_slope_run(),
142            caret_offset: obj.caret_offset(),
143            number_of_long_ver_metrics: obj.number_of_long_ver_metrics(),
144        }
145    }
146}
147
148#[allow(clippy::needless_lifetimes)]
149impl<'a> FromTableRef<read_fonts::tables::vhea::Vhea<'a>> for Vhea {}
150
151impl ReadArgs for Vhea {
152    type Args = ();
153}
154
155impl<'a> FontRead<'a> for Vhea {
156    fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
157        <read_fonts::tables::vhea::Vhea as FontRead>::read(data).map(|x| x.to_owned_table())
158    }
159}
160
161/// VHEA header table (ISO/IEC 14496-22:2026, 5.6.13).
162#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
163#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
164pub struct VheaExtended {
165    pub version: Version16Dot16,
166    pub ascender: FWord,
167    pub descender: FWord,
168    pub line_gap: FWord,
169    pub advance_height_max: FWord,
170    pub min_top_side_bearing: FWord,
171    pub min_bottom_side_bearing: FWord,
172    pub y_max_extent: FWord,
173    pub caret_slope_rise: i16,
174    pub caret_slope_run: i16,
175    pub caret_offset: i16,
176    /// Number of long metric records in VMTX.
177    pub number_of_long_ver_metrics: u32,
178}
179
180impl Default for VheaExtended {
181    fn default() -> Self {
182        Self {
183            version: Version16Dot16::VERSION_1_1,
184            ascender: Default::default(),
185            descender: Default::default(),
186            line_gap: Default::default(),
187            advance_height_max: Default::default(),
188            min_top_side_bearing: Default::default(),
189            min_bottom_side_bearing: Default::default(),
190            y_max_extent: Default::default(),
191            caret_slope_rise: Default::default(),
192            caret_slope_run: Default::default(),
193            caret_offset: Default::default(),
194            number_of_long_ver_metrics: Default::default(),
195        }
196    }
197}
198
199impl VheaExtended {
200    /// Construct a new `VheaExtended`
201    #[allow(clippy::too_many_arguments)]
202    pub fn new(
203        ascender: FWord,
204        descender: FWord,
205        line_gap: FWord,
206        advance_height_max: FWord,
207        min_top_side_bearing: FWord,
208        min_bottom_side_bearing: FWord,
209        y_max_extent: FWord,
210        caret_slope_rise: i16,
211        caret_slope_run: i16,
212        caret_offset: i16,
213        number_of_long_ver_metrics: u32,
214    ) -> Self {
215        Self {
216            ascender,
217            descender,
218            line_gap,
219            advance_height_max,
220            min_top_side_bearing,
221            min_bottom_side_bearing,
222            y_max_extent,
223            caret_slope_rise,
224            caret_slope_run,
225            caret_offset,
226            number_of_long_ver_metrics,
227            ..Default::default()
228        }
229    }
230}
231
232impl FontWrite for VheaExtended {
233    #[allow(clippy::unnecessary_cast)]
234    fn write_into(&self, writer: &mut TableWriter) {
235        self.version.write_into(writer);
236        self.ascender.write_into(writer);
237        self.descender.write_into(writer);
238        self.line_gap.write_into(writer);
239        self.advance_height_max.write_into(writer);
240        self.min_top_side_bearing.write_into(writer);
241        self.min_bottom_side_bearing.write_into(writer);
242        self.y_max_extent.write_into(writer);
243        self.caret_slope_rise.write_into(writer);
244        self.caret_slope_run.write_into(writer);
245        self.caret_offset.write_into(writer);
246        (0 as i16).write_into(writer);
247        (0 as i16).write_into(writer);
248        (0 as i16).write_into(writer);
249        (0 as i16).write_into(writer);
250        (0 as i16).write_into(writer);
251        self.number_of_long_ver_metrics.write_into(writer);
252    }
253    fn table_type(&self) -> TableType {
254        TableType::TopLevel(VheaExtended::TAG)
255    }
256}
257
258impl Validate for VheaExtended {
259    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
260}
261
262impl TopLevelTable for VheaExtended {
263    const TAG: Tag = Tag::new(b"VHEA");
264}
265
266impl<'a> FromObjRef<read_fonts::tables::vhea::VheaExtended<'a>> for VheaExtended {
267    fn from_obj_ref(obj: &read_fonts::tables::vhea::VheaExtended<'a>, _: FontData) -> Self {
268        VheaExtended {
269            version: obj.version(),
270            ascender: obj.ascender(),
271            descender: obj.descender(),
272            line_gap: obj.line_gap(),
273            advance_height_max: obj.advance_height_max(),
274            min_top_side_bearing: obj.min_top_side_bearing(),
275            min_bottom_side_bearing: obj.min_bottom_side_bearing(),
276            y_max_extent: obj.y_max_extent(),
277            caret_slope_rise: obj.caret_slope_rise(),
278            caret_slope_run: obj.caret_slope_run(),
279            caret_offset: obj.caret_offset(),
280            number_of_long_ver_metrics: obj.number_of_long_ver_metrics(),
281        }
282    }
283}
284
285#[allow(clippy::needless_lifetimes)]
286impl<'a> FromTableRef<read_fonts::tables::vhea::VheaExtended<'a>> for VheaExtended {}
287
288impl ReadArgs for VheaExtended {
289    type Args = ();
290}
291
292impl<'a> FontRead<'a> for VheaExtended {
293    fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
294        <read_fonts::tables::vhea::VheaExtended as FontRead>::read(data).map(|x| x.to_owned_table())
295    }
296}