/src/fontations/write-fonts/generated/generated_hhea.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 | | /// [hhea](https://docs.microsoft.com/en-us/typography/opentype/spec/hhea) Horizontal Header Table |
9 | | #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] |
10 | | #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] |
11 | | pub struct Hhea { |
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 width value in 'hmtx' table. |
20 | | pub advance_width_max: UfWord, |
21 | | /// Minimum left sidebearing value in 'hmtx' table for glyphs with |
22 | | /// contours (empty glyphs should be ignored). |
23 | | pub min_left_side_bearing: FWord, |
24 | | /// Minimum right sidebearing value; calculated as min(aw - (lsb + |
25 | | /// xMax - xMin)) for glyphs with contours (empty glyphs should be ignored). |
26 | | pub min_right_side_bearing: FWord, |
27 | | /// Max(lsb + (xMax-xMin)) |
28 | | pub x_max_extent: FWord, |
29 | | /// Used to calculate the slope of the cursor (rise/run); 1 for |
30 | | /// vertical caret, 0 for horizontal. |
31 | | pub caret_slope_rise: i16, |
32 | | /// 0 for vertical caret, 1 for horizontal. |
33 | | pub caret_slope_run: i16, |
34 | | /// The amount by which a slanted highlight on a glyph needs to be |
35 | | /// shifted to produce the best appearance. Set to 0 for |
36 | | /// non-slanted fonts |
37 | | pub caret_offset: i16, |
38 | | /// Number of hMetric entries in 'hmtx' table |
39 | | pub number_of_h_metrics: u16, |
40 | | } |
41 | | |
42 | | impl Hhea { |
43 | | /// Construct a new `Hhea` |
44 | | #[allow(clippy::too_many_arguments)] |
45 | 0 | pub fn new( |
46 | 0 | ascender: FWord, |
47 | 0 | descender: FWord, |
48 | 0 | line_gap: FWord, |
49 | 0 | advance_width_max: UfWord, |
50 | 0 | min_left_side_bearing: FWord, |
51 | 0 | min_right_side_bearing: FWord, |
52 | 0 | x_max_extent: FWord, |
53 | 0 | caret_slope_rise: i16, |
54 | 0 | caret_slope_run: i16, |
55 | 0 | caret_offset: i16, |
56 | 0 | number_of_h_metrics: u16, |
57 | 0 | ) -> Self { |
58 | 0 | Self { |
59 | 0 | ascender, |
60 | 0 | descender, |
61 | 0 | line_gap, |
62 | 0 | advance_width_max, |
63 | 0 | min_left_side_bearing, |
64 | 0 | min_right_side_bearing, |
65 | 0 | x_max_extent, |
66 | 0 | caret_slope_rise, |
67 | 0 | caret_slope_run, |
68 | 0 | caret_offset, |
69 | 0 | number_of_h_metrics, |
70 | 0 | } |
71 | 0 | } |
72 | | } |
73 | | |
74 | | impl FontWrite for Hhea { |
75 | | #[allow(clippy::unnecessary_cast)] |
76 | 0 | fn write_into(&self, writer: &mut TableWriter) { |
77 | 0 | (MajorMinor::VERSION_1_0 as MajorMinor).write_into(writer); |
78 | 0 | self.ascender.write_into(writer); |
79 | 0 | self.descender.write_into(writer); |
80 | 0 | self.line_gap.write_into(writer); |
81 | 0 | self.advance_width_max.write_into(writer); |
82 | 0 | self.min_left_side_bearing.write_into(writer); |
83 | 0 | self.min_right_side_bearing.write_into(writer); |
84 | 0 | self.x_max_extent.write_into(writer); |
85 | 0 | self.caret_slope_rise.write_into(writer); |
86 | 0 | self.caret_slope_run.write_into(writer); |
87 | 0 | self.caret_offset.write_into(writer); |
88 | 0 | (0 as i16).write_into(writer); |
89 | 0 | (0 as i16).write_into(writer); |
90 | 0 | (0 as i16).write_into(writer); |
91 | 0 | (0 as i16).write_into(writer); |
92 | 0 | (0 as i16).write_into(writer); |
93 | 0 | self.number_of_h_metrics.write_into(writer); |
94 | 0 | } |
95 | 0 | fn table_type(&self) -> TableType { |
96 | 0 | TableType::TopLevel(Hhea::TAG) |
97 | 0 | } |
98 | | } |
99 | | |
100 | | impl Validate for Hhea { |
101 | 0 | fn validate_impl(&self, _ctx: &mut ValidationCtx) {} |
102 | | } |
103 | | |
104 | | impl TopLevelTable for Hhea { |
105 | | const TAG: Tag = Tag::new(b"hhea"); |
106 | | } |
107 | | |
108 | | impl<'a> FromObjRef<read_fonts::tables::hhea::Hhea<'a>> for Hhea { |
109 | 0 | fn from_obj_ref(obj: &read_fonts::tables::hhea::Hhea<'a>, _: FontData) -> Self { |
110 | 0 | Hhea { |
111 | 0 | ascender: obj.ascender(), |
112 | 0 | descender: obj.descender(), |
113 | 0 | line_gap: obj.line_gap(), |
114 | 0 | advance_width_max: obj.advance_width_max(), |
115 | 0 | min_left_side_bearing: obj.min_left_side_bearing(), |
116 | 0 | min_right_side_bearing: obj.min_right_side_bearing(), |
117 | 0 | x_max_extent: obj.x_max_extent(), |
118 | 0 | caret_slope_rise: obj.caret_slope_rise(), |
119 | 0 | caret_slope_run: obj.caret_slope_run(), |
120 | 0 | caret_offset: obj.caret_offset(), |
121 | 0 | number_of_h_metrics: obj.number_of_h_metrics(), |
122 | 0 | } |
123 | 0 | } |
124 | | } |
125 | | |
126 | | #[allow(clippy::needless_lifetimes)] |
127 | | impl<'a> FromTableRef<read_fonts::tables::hhea::Hhea<'a>> for Hhea {} |
128 | | |
129 | | impl ReadArgs for Hhea { |
130 | | type Args = (); |
131 | | } |
132 | | |
133 | | impl<'a> FontRead<'a> for Hhea { |
134 | 0 | fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> { |
135 | 0 | <read_fonts::tables::hhea::Hhea as FontRead>::read(data).map(|x| x.to_owned_table()) |
136 | 0 | } |
137 | | } |