pub trait FontSource {
// Required methods
fn family(&mut self, name: &str) -> Vec<Font>;
fn face_for_codepoint(
&mut self,
codepoint: char,
attrs: FontAttrs,
) -> Option<Font>;
// Provided method
fn default_face(&mut self, attrs: FontAttrs) -> Option<Font> { ... }
}Expand description
FontSource locates fonts that are not already registered.
A source may consult installed fonts, downloaded assets, or another
host-owned repository. FontCollection consults sources in registration
order.
Required Methods§
Provided Methods§
Sourcefn default_face(&mut self, attrs: FontAttrs) -> Option<Font>
fn default_face(&mut self, attrs: FontAttrs) -> Option<Font>
default_face returns the source’s default face nearest to attrs, the face text
is set in when no family it asks for has one: Skia’s
SkFontMgr::legacyMakeTypeface(nullptr, style). A collection asks for it only while
it has no face at all.
The default answers None: a source without a default leaves an empty collection’s
text to its character lookup, and what that misses to the collection’s demand, for a
host that loads fonts asynchronously.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".