use std::path::PathBuf;
use std::sync::Arc;
use crate::error::FontLoadingError;
use crate::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)
}
}