1use crate::types::Tag;
2
3mod directory;
4pub use directory::*;
5
6pub mod cmap;
7pub mod head;
8pub mod hhea;
9pub mod hmtx;
10pub mod maxp;
11pub mod name;
12
13pub trait Table {
14 const TAG: Tag;
15 type Handle<'a>: TableHandle<'a>;
16 fn in_directory(dir: &TableDirectoryRepr) -> Option<Self::Handle<'_>> {
17 Self::Handle::in_directory(dir)
18 }
19}
20
21pub trait TableHandle<'a>: Sized {
22 fn in_directory(dir: &'a TableDirectoryRepr) -> Option<Self>;
23}
24
25impl<'a, T: Table> TableHandle<'a> for &'a T {
26 fn in_directory(dir: &'a TableDirectoryRepr) -> Option<Self> {
27 dir.table_raw::<T>()
28 }
29}
30
31impl TableDirectoryRepr {
32 pub fn cmap(&self) -> Option<&cmap::CmapTableRepr> {
34 self.table()
35 }
36 pub fn head(&self) -> Option<&head::HeadTableRepr> {
37 self.table()
38 }
39 pub fn hhea(&self) -> Option<&hhea::HheaTableRepr> {
40 self.table()
41 }
42 pub fn hmtx(&self) -> Option<hmtx::HmtxTableHandle<'_>> {
43 self.table()
44 }
45 pub fn maxp(&self) -> Option<&maxp::MaxpTableRepr> {
46 self.table()
47 }
48 pub fn name(&self) -> Option<&name::NameTableRepr> {
49 self.table()
50 }
51}