Skip to main content

FontCollection

Struct FontCollection 

Source
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

Source

pub fn new() -> FontCollection

Source

pub fn faces(&self) -> &FaceSet

The faces resolved so far — what a built paragraph snapshots.

Source

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.

Source

pub fn add(&mut self, font: Font) -> FontId

Source

pub fn add_fallback(&mut self, id: FontId)

Source

pub fn get(&self, id: FontId) -> &Font

Source

pub fn len(&self) -> usize

Source

pub fn family(&self, name: &str) -> Option<FontId>

Source

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.

Source

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.

Source

pub fn is_empty(&self) -> bool

Source

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).

Source

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.

Trait Implementations§

Source§

impl Default for FontCollection

Source§

fn default() -> FontCollection

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.