Skip to main content

read_fonts/tables/
vmtx.rs

1//! The [vmtx (Vertical Metrics)](https://docs.microsoft.com/en-us/typography/opentype/spec/vmtx) table
2
3use super::hmtx;
4pub use super::hmtx::LongMetric;
5
6include!("../../generated/generated_vmtx.rs");
7
8macro_rules! impl_vmtx_lookup {
9    ($table:ident) => {
10        impl $table<'_> {
11            /// Returns the advance height for the given glyph identifier.
12            pub fn advance(&self, glyph_id: GlyphId) -> Option<u16> {
13                hmtx::advance(self.v_metrics(), glyph_id)
14            }
15
16            /// Returns the top side bearing for the given glyph identifier.
17            pub fn side_bearing(&self, glyph_id: GlyphId) -> Option<i16> {
18                hmtx::side_bearing(self.v_metrics(), self.top_side_bearings(), glyph_id)
19            }
20        }
21    };
22}
23
24impl_vmtx_lookup!(Vmtx);
25impl_vmtx_lookup!(VmtxExtended);