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
use std::io::{Read, Seek};
use std::path::Path;

use {Font, Result};
use format::opentype;

/// A file.
pub struct File {
    /// The fonts.
    pub fonts: Vec<Font>,
}

impl File {
    /// Open a file.
    #[inline]
    pub fn open<T: AsRef<Path>>(path: T) -> Result<Self> {
        File::read(&mut try!(::std::fs::File::open(path)))
    }

    /// Read a file.
    #[inline]
    pub fn read<T: Read + Seek>(tape: &mut T) -> Result<Self> {
        Ok(File { fonts: try!(opentype::read(tape)) })
    }
}

deref! { File::fonts => [Font] }