1use super::parse_prelude::*;
4
5pub const VORG: Tag = Tag::new(b"VORG");
7
8#[derive(Copy, Clone, Debug)]
10pub struct VyMetric {
11 pub gid: GlyphId,
12 pub y: FWord,
13}
14
15impl ReadData for VyMetric {
16 unsafe fn read_data_unchecked(buf: &[u8], offset: usize) -> Self {
17 Self {
18 gid: u16::read_data_unchecked(buf, offset),
19 y: i16::read_data_unchecked(buf, offset + 2),
20 }
21 }
22}
23
24#[derive(Copy, Clone)]
28pub struct Vorg<'a>(Buffer<'a>);
29
30impl<'a> Vorg<'a> {
31 pub fn new(data: &'a [u8]) -> Self {
34 Self(Buffer::new(data))
35 }
36
37 pub fn major_version(&self) -> u16 {
39 self.0.read(0).unwrap_or(0)
40 }
41
42 pub fn minor_version(&self) -> u16 {
44 self.0.read(2).unwrap_or(0)
45 }
46
47 pub fn default_vymetric(&self) -> FWord {
50 self.0.read(4).unwrap_or(0)
51 }
52
53 pub fn vymetrics(&self) -> Slice<'a, VyMetric> {
56 self.0.read_slice16(8).unwrap_or_default()
57 }
58}