Skip to main content

read_fonts/tables/
vhea.rs

1//! the [vhea (Vertical Header)](https://docs.microsoft.com/en-us/typography/opentype/spec/vhea) table
2
3include!("../../generated/generated_vhea.rs");
4
5/// A vertical header from VHEA or vhea.
6#[derive(Clone)]
7pub enum SelectedVhea<'a> {
8    /// The original `vhea` table.
9    Original(Vhea<'a>),
10    /// The `VHEA` table (ISO/IEC 14496-22:2026).
11    Extended(VheaExtended<'a>),
12}
13
14impl SelectedVhea<'_> {
15    /// Number of long metric records.
16    pub fn number_of_long_ver_metrics(&self) -> u32 {
17        match self {
18            Self::Original(table) => table.number_of_long_ver_metrics().into(),
19            Self::Extended(table) => table.number_of_long_ver_metrics(),
20        }
21    }
22
23    /// Maximum advance height.
24    ///
25    /// VHEA states this as a signed value, which is read as unsigned like
26    /// that of vhea, HHEA and hhea.
27    pub fn advance_height_max(&self) -> UfWord {
28        match self {
29            Self::Original(table) => table.advance_height_max(),
30            Self::Extended(table) => UfWord::new(table.advance_height_max().to_i16() as u16),
31        }
32    }
33
34    selected_table_getters!(
35        version -> Version16Dot16,
36        ascender -> FWord,
37        descender -> FWord,
38        line_gap -> FWord,
39        min_top_side_bearing -> FWord,
40        min_bottom_side_bearing -> FWord,
41        y_max_extent -> FWord,
42        caret_slope_rise -> i16,
43        caret_slope_run -> i16,
44        caret_offset -> i16,
45        metric_data_format -> i16,
46    );
47}