-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Captures lookup of all the AAT types into a new type and builds them directly from table data rather than going through `ttf_parser::Face`. This will allow us to remove `ttf_parser::Face` from `hb_font_t` before AAT support in `read-fonts` is done and will enable us to replace those tables one at a time.
- Loading branch information
Showing
8 changed files
with
71 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use core::num::NonZeroU16; | ||
use skrifa::raw::{types::Tag, FontRef, TableProvider}; | ||
use ttf_parser::{ | ||
ankr::Table as Ankr, feat::Table as Feat, kern::Table as Kern, kerx::Table as Kerx, | ||
morx::Table as Morx, trak::Table as Trak, | ||
}; | ||
|
||
#[derive(Clone, Default)] | ||
pub struct AatTables<'a> { | ||
pub morx: Option<Morx<'a>>, | ||
pub ankr: Option<Ankr<'a>>, | ||
pub kern: Option<Kern<'a>>, | ||
pub kerx: Option<Kerx<'a>>, | ||
pub trak: Option<Trak<'a>>, | ||
pub feat: Option<Feat<'a>>, | ||
} | ||
|
||
impl<'a> AatTables<'a> { | ||
pub fn new(font: &FontRef<'a>) -> Self { | ||
let Some(num_glyphs) = NonZeroU16::new( | ||
font.maxp() | ||
.map(|maxp| maxp.num_glyphs()) | ||
.unwrap_or_default(), | ||
) else { | ||
return Self::default(); | ||
}; | ||
Self { | ||
morx: font | ||
.table_data(Tag::new(b"morx")) | ||
.and_then(|data| Morx::parse(num_glyphs, data.as_bytes())), | ||
ankr: font | ||
.table_data(Tag::new(b"ankr")) | ||
.and_then(|data| Ankr::parse(num_glyphs, data.as_bytes())), | ||
kern: font | ||
.table_data(Tag::new(b"kern")) | ||
.and_then(|data| Kern::parse(data.as_bytes())), | ||
kerx: font | ||
.table_data(Tag::new(b"kerx")) | ||
.and_then(|data| Kerx::parse(num_glyphs, data.as_bytes())), | ||
trak: font | ||
.table_data(Tag::new(b"trak")) | ||
.and_then(|data| Trak::parse(data.as_bytes())), | ||
feat: font | ||
.table_data(Tag::new(b"feat")) | ||
.and_then(|data| Feat::parse(data.as_bytes())), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters