Make refactor into library

This commit is contained in:
Jeremy Soller 2022-10-05 09:16:51 -06:00
parent 132fb02008
commit 3295b254ad
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE
8 changed files with 449 additions and 439 deletions

View file

@ -0,0 +1,33 @@
pub use self::layout::*;
mod layout;
pub use self::matches::*;
mod matches;
pub use self::shape::*;
mod shape;
pub use self::system::*;
mod system;
pub struct Font<'a> {
data: &'a [u8],
pub rustybuzz: rustybuzz::Face<'a>,
#[cfg(feature = "ab_glyph")]
pub ab_glyph: ab_glyph::FontRef<'a>,
#[cfg(feature = "rusttype")]
pub rusttype: rusttype::Font<'a>,
}
impl<'a> Font<'a> {
pub fn new(data: &'a [u8], index: u32) -> Option<Self> {
Some(Self {
data,
rustybuzz: rustybuzz::Face::from_slice(data, index)?,
#[cfg(feature = "ab_glyph")]
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)?,
})
}
}