pub struct FontCollection { /* private fields */ }Expand description
Faces plus the sources that can find more — Skia’s FontCollection
(skparagraph FontCollection.h: the asset/dynamic/default SkFontMgrs
live INSIDE the collection, and findTypefaces/defaultFallback are
its methods). Shaping consults this at every miss; what no source can
answer accumulates as the demand a host
fetches asynchronously (Flutter web’s _unprocessedCodePoints).
Implementations§
Source§impl FontCollection
impl FontCollection
pub fn new() -> FontCollection
Sourcepub fn register(&mut self, family: &str, bytes: Vec<u8>) -> Option<FontId>
pub fn register(&mut self, family: &str, bytes: Vec<u8>) -> Option<FontId>
Registers bytes under a family (Skia registerTypeface; Flutter
FontLoader.load). Host-facing: the other half of the async loop.
pub fn add(&mut self, font: Font) -> FontId
pub fn add_fallback(&mut self, id: FontId)
pub fn get(&self, id: FontId) -> &Font
pub fn len(&self) -> usize
pub fn family(&self, name: &str) -> Option<FontId>
Sourcepub fn add_source(&mut self, source: impl FontSource + 'static)
pub fn add_source(&mut self, source: impl FontSource + 'static)
Adds a source consulted on a miss: the OS database, a downloader’s already-fetched cache, anything.
Sourcepub fn add_boxed_source(&mut self, source: Box<dyn FontSource>)
pub fn add_boxed_source(&mut self, source: Box<dyn FontSource>)
add_source for an already-boxed source — what
a platform hands the framework through a trait object.
pub fn is_empty(&self) -> bool
Sourcepub fn adopt_faces(&mut self, faces: FaceSet)
pub fn adopt_faces(&mut self, faces: FaceSet)
Replaces the faces with a set grown out of band (a host that
answered a demand itself — FaceSet::grown_by).
Sourcepub fn take_unanswered(&mut self) -> FontDemand
pub fn take_unanswered(&mut self) -> FontDemand
Takes the misses no source could answer — the host’s cue to fetch
(and later register, which invalidates the text
that wanted them). Draining is the caller’s; nothing here is async.