1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
use std::path::Path;
use typeface::Tape;
use crate::Result;
/// A file.
pub struct File {
/// The fonts.
pub fonts: Vec<crate::font::Font>,
}
impl File {
/// Open a file.
#[inline]
pub fn open<T: AsRef<Path>>(path: T) -> Result<Self> {
Self::read(std::fs::File::open(path)?)
}
/// Read a file.
#[inline]
pub fn read<T: Tape + 'static>(tape: T) -> Result<Self> {
Ok(Self {
fonts: crate::font::read(tape)?,
})
}
}
dereference! { File::fonts => [crate::font::Font] }