Skip to main content

ferroui_base/media/fonts/
embedded_font_collection.rs

1use crate::media::fonts::{FontCollectionBase, FontCollectionBaseImpl};
2use crate::utilities::Uri;
3
4/// A font collection of the fonts found at a source: application assets
5/// (`ferres:`, `resm:`), a font file or a directory of font files (`file:`).
6pub struct EmbeddedFontCollection {
7    base: FontCollectionBase,
8    key: Uri,
9    source: Uri,
10}
11
12impl EmbeddedFontCollection {
13    /// Creates the collection identified by `key` and loads the fonts of
14    /// `source` into it.
15    pub fn new(key: Uri, source: Uri) -> Self {
16        let collection = Self { base: FontCollectionBase::new(), key, source };
17
18        FontCollectionBase::try_add_font_source(&collection, &collection.source);
19
20        collection
21    }
22}
23
24impl FontCollectionBaseImpl for EmbeddedFontCollection {
25    fn base(this: &Self) -> &FontCollectionBase {
26        &this.base
27    }
28
29    fn key(this: &Self) -> Uri {
30        this.key.clone()
31    }
32}