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, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
10#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11pub struct Vhea {
12    /// Typographic ascent.
13    pub ascender: FWord,
14    /// Typographic descent.
15    pub descender: FWord,
16    /// Typographic line gap. Negative LineGap values are treated as
17    /// zero in some legacy platform implementations.
18    pub line_gap: FWord,
19    /// Maximum advance height value in 'vmtx' table.
20    pub advance_height_max: UfWord,
21    /// Minimum top sidebearing value in 'vmtx' table for glyphs with
22    /// contours (empty glyphs should be ignored).
23    pub min_top_side_bearing: FWord,
24    /// Minimum bottom sidebearing value
25    pub min_bottom_side_bearing: FWord,
26    /// Defined as max( tsb + (yMax-yMin)).
27    pub y_max_extent: FWord,
28    /// Used to calculate the slope of the cursor (rise/run); 1 for
29    /// vertical caret, 0 for horizontal.
30    pub caret_slope_rise: i16,
31    /// 0 for vertical caret, 1 for horizontal.
32    pub caret_slope_run: i16,
33    /// The amount by which a slanted highlight on a glyph needs to be
34    /// shifted to produce the best appearance. Set to 0 for
35    /// non-slanted fonts
36    pub caret_offset: i16,
37    /// Number of advance heights in the vertical metrics (`vmtx`) table.
38    pub number_of_long_ver_metrics: u16,
39}
40
41impl Vhea {
42    /// Construct a new `Vhea`
43    #[allow(clippy::too_many_arguments)]
44    pub fn new(
45        ascender: FWord,
46        descender: FWord,
47        line_gap: FWord,
48        advance_height_max: UfWord,
49        min_top_side_bearing: FWord,
50        min_bottom_side_bearing: FWord,
51        y_max_extent: FWord,
52        caret_slope_rise: i16,
53        caret_slope_run: i16,
54        caret_offset: i16,
55        number_of_long_ver_metrics: u16,
56    ) -> Self {
57        Self {
58            ascender,
59            descender,
60            line_gap,
61            advance_height_max,
62            min_top_side_bearing,
63            min_bottom_side_bearing,
64            y_max_extent,
65            caret_slope_rise,
66            caret_slope_run,
67            caret_offset,
68            number_of_long_ver_metrics,
69        }
70    }
71}
72
73impl FontWrite for Vhea {
74    #[allow(clippy::unnecessary_cast)]
75    fn write_into(&self, writer: &mut TableWriter) {
76        (Version16Dot16::VERSION_1_1 as Version16Dot16).write_into(writer);
77        self.ascender.write_into(writer);
78        self.descender.write_into(writer);
79        self.line_gap.write_into(writer);
80        self.advance_height_max.write_into(writer);
81        self.min_top_side_bearing.write_into(writer);
82        self.min_bottom_side_bearing.write_into(writer);
83        self.y_max_extent.write_into(writer);
84        self.caret_slope_rise.write_into(writer);
85        self.caret_slope_run.write_into(writer);
86        self.caret_offset.write_into(writer);
87        (0 as i16).write_into(writer);
88        (0 as i16).write_into(writer);
89        (0 as i16).write_into(writer);
90        (0 as i16).write_into(writer);
91        (0 as i16).write_into(writer);
92        self.number_of_long_ver_metrics.write_into(writer);
93    }
94    fn table_type(&self) -> TableType {
95        TableType::TopLevel(Vhea::TAG)
96    }
97}
98
99impl Validate for Vhea {
100    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
101}
102
103impl TopLevelTable for Vhea {
104    const TAG: Tag = Tag::new(b"vhea");
105}
106
107impl<'a> FromObjRef<read_fonts::tables::vhea::Vhea<'a>> for Vhea {
108    fn from_obj_ref(obj: &read_fonts::tables::vhea::Vhea<'a>, _: FontData) -> Self {
109        Vhea {
110            ascender: obj.ascender(),
111            descender: obj.descender(),
112            line_gap: obj.line_gap(),
113            advance_height_max: obj.advance_height_max(),
114            min_top_side_bearing: obj.min_top_side_bearing(),
115            min_bottom_side_bearing: obj.min_bottom_side_bearing(),
116            y_max_extent: obj.y_max_extent(),
117            caret_slope_rise: obj.caret_slope_rise(),
118            caret_slope_run: obj.caret_slope_run(),
119            caret_offset: obj.caret_offset(),
120            number_of_long_ver_metrics: obj.number_of_long_ver_metrics(),
121        }
122    }
123}
124
125#[allow(clippy::needless_lifetimes)]
126impl<'a> FromTableRef<read_fonts::tables::vhea::Vhea<'a>> for Vhea {}
127
128impl<'a> FontRead<'a> for Vhea {
129    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
130        <read_fonts::tables::vhea::Vhea as FontRead>::read(data).map(|x| x.to_owned_table())
131    }
132}