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
use std::io::Result;
use std::path::Path;

/// 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: typeface::tape::Read + 'static>(tape: T) -> Result<Self> {
        Ok(Self {
            fonts: crate::font::read(tape)?,
        })
    }
}

dereference! { File::fonts => [crate::font::Font] }