IFontCollection
trait · ferroui-base · v0.5.0
trait IFontCollection: 'static
Represents a collection of font families and provides methods for retrieving font-related information, such as glyph typefaces and fallback characters.
The collection is a read-only list of FontFamily (count, get,
font_families). Handles are Rc<dyn IFontCollection>.
A custom collection either implements this trait directly, or implements
FontCollectionBaseImpl to
reuse the matching, fallback and caching logic of
FontCollectionBase (this
trait is then implemented automatically).
Members
keycountgetfont_familiestry_get_glyph_typefacetry_match_charactertry_get_family_typefacestry_create_synthetic_glyph_typefacetry_get_nearest_matchdisposeas_font_collection_baseas_any
key
fn key(self: &Self) -> url::Url
Gets the unique identifier for the font collection: a URL of the
fonts: scheme for a collection added to the font manager
(fonts:SystemFonts, fonts:Inter).
count
fn count(self: &Self) -> usize
The number of font families in the collection.
get
fn get(self: &Self, index: usize) -> FontFamily
The font family at index.
Panics when index is out of range.
font_families
fn font_families(self: &Self) -> Vec<FontFamily>
A snapshot of the font families of the collection, in order.
try_get_glyph_typeface
fn try_get_glyph_typeface(self: &Self, family_name: &str, style: FontStyle, weight: FontWeight, stretch: FontStretch) -> Option<Rc<GlyphTypeface>>
Try to get a glyph typeface for given parameters.
try_match_character
fn try_match_character(self: &Self, codepoint: i32, font_style: FontStyle, font_weight: FontWeight, font_stretch: FontStretch, family_name: Option<&str>, culture: Option<&Locale>) -> Option<Typeface>
Tries to match a specified character to a Typeface that supports
specified font properties.
family_name is optional and used for fallback lookup.
try_get_family_typefaces
fn try_get_family_typefaces(self: &Self, family_name: &str) -> Option<Vec<Typeface>>
Tries to get a list of typefaces for the specified family name.
try_create_synthetic_glyph_typeface
fn try_create_synthetic_glyph_typeface(self: &Self, glyph_typeface: &Rc<GlyphTypeface>, style: FontStyle, weight: FontWeight, stretch: FontStretch) -> Option<Rc<GlyphTypeface>>
Try to get a synthetic glyph typeface for given parameters.
try_get_nearest_match
fn try_get_nearest_match(self: &Self, family_name: &str, style: FontStyle, weight: FontWeight, stretch: FontStretch) -> Option<Rc<GlyphTypeface>>
Attempts to retrieve the glyph typeface that most closely matches the specified font family name, style, weight, and stretch.
This method searches for a glyph typeface in the font collection cache
that matches the specified parameters. If an exact match is not found,
fallback mechanisms are applied to find the closest match based on the
specified style, weight, and stretch. If no suitable match is found,
None is returned.
dispose
fn dispose(self: &Self)
Releases the glyph typefaces held by the collection (C# IDisposable.Dispose).
as_font_collection_base
fn as_font_collection_base(self: &Self) -> Option<&dyn IFontCollectionBase>
The collection viewed as a FontCollectionBase derived collection, if
it is one (C# collection is FontCollectionBase).
as_any
fn as_any(self: &Self) -> &dyn Any
Lets callers recover the concrete collection type.
Trait implementations
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.