use error::FontLoadingError;
use family_handle::FamilyHandle;
use font::Font;
use handle::Handle;
use loader::Loader;
#[derive(Debug)]
pub struct Family<F = Font> where F: Loader {
fonts: Vec<F>,
}
impl<F> Family<F> where F: Loader {
pub(crate) fn from_font_handles<'a, I>(font_handles: I) -> Result<Family<F>, FontLoadingError>
where I: Iterator<Item = &'a Handle> {
let mut fonts = vec![];
for font_handle in font_handles {
fonts.push(try!(F::from_handle(font_handle)))
}
Ok(Family {
fonts,
})
}
#[inline]
pub(crate) fn from_handle(family_handle: &FamilyHandle)
-> Result<Family<F>, FontLoadingError> {
Family::from_font_handles(family_handle.fonts.iter())
}
#[inline]
pub fn fonts(&self) -> &[F] {
&self.fonts
}
#[inline]
pub fn is_empty(&self) -> bool {
self.fonts.is_empty()
}
}