Add support for swash

This commit is contained in:
Jeremy Soller 2022-10-07 09:41:36 -06:00
parent 51639e53cb
commit cf43655357
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE
7 changed files with 116 additions and 66 deletions

View file

@ -30,6 +30,8 @@ pub struct Font<'a> {
pub ab_glyph: ab_glyph::FontRef<'a>,
#[cfg(feature = "rusttype")]
pub rusttype: rusttype::Font<'a>,
#[cfg(feature = "swash")]
pub swash: swash::FontRef<'a>,
}
impl<'a> Font<'a> {
@ -41,6 +43,8 @@ impl<'a> Font<'a> {
ab_glyph: ab_glyph::FontRef::try_from_slice_and_index(data, index).ok()?,
#[cfg(feature = "rusttype")]
rusttype: rusttype::Font::try_from_bytes_and_index(data, index)?,
#[cfg(feature = "swash")]
swash: swash::FontRef::from_index(data, index as usize)?,
})
}
}