use std::path::PathBuf;
use std::sync::Arc;
use error::FontLoadingError;
use font::Font;
#[derive(Debug, Clone)]
pub enum Handle {
Path {
path: PathBuf,
font_index: u32,
},
Memory {
bytes: Arc<Vec<u8>>,
font_index: u32,
},
}
impl Handle {
#[inline]
pub fn from_path(path: PathBuf, font_index: u32) -> Handle {
Handle::Path {
path,
font_index,
}
}
#[inline]
pub fn from_memory(bytes: Arc<Vec<u8>>, font_index: u32) -> Handle {
Handle::Memory {
bytes,
font_index,
}
}
#[inline]
pub fn load(&self) -> Result<Font, FontLoadingError> {
Font::from_handle(self)
}
}