diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-01-15 16:53:02 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-01-15 16:53:02 +0100 |
| commit | d763f0f5a6a700352ee8926c15c8e58624f705c9 (patch) | |
| tree | d287edfdab9793a796404516c7313689e4e69964 /src/font.rs | |
| parent | 0f0416054f263b80ccec1a463ce4ab20913bdf71 (diff) | |
Split state and scopes, less ref-counting 🔀
Diffstat (limited to 'src/font.rs')
| -rw-r--r-- | src/font.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/font.rs b/src/font.rs index 40ec5918..01ea48c0 100644 --- a/src/font.rs +++ b/src/font.rs @@ -3,6 +3,9 @@ use fontdock::{ContainsChar, FaceFromVec, FontSource}; use ttf_parser::Face; +#[cfg(feature = "fs")] +use fontdock::fs::{FsIndex, FsSource}; + /// A font loader that is backed by a dynamic source. pub type FontLoader = fontdock::FontLoader<Box<dyn FontSource<Face = FaceBuf>>>; @@ -47,3 +50,18 @@ impl ContainsChar for FaceBuf { self.get().glyph_index(c).is_some() } } + +#[cfg(feature = "fs")] +pub trait FsIndexExt { + /// Create a font loader backed by a boxed [`FsSource`] which serves all + /// indexed font faces. + fn into_dynamic_loader(self) -> FontLoader; +} + +#[cfg(feature = "fs")] +impl FsIndexExt for FsIndex { + fn into_dynamic_loader(self) -> FontLoader { + let (files, descriptors) = self.into_vecs(); + FontLoader::new(Box::new(FsSource::new(files)), descriptors) + } +} |
