Struct kas_text::fonts::Database

source ·
pub struct Database { /* private fields */ }
Expand description

Manages the list of available fonts and font selection

This database exists as a singleton, accessible through the fonts function.

After initialization font loading and alias adjustment is disabled. The reason for this is that font selection uses multiple caches and there is no mechanism for forcing fresh lookups everywhere.

Implementations§

Access the database

Access the list of discovered font families

All family names are uppercase.

List all font family alias keys

All family names are uppercase.

List all aliases for the given family

The family parameter must be upper case (or no matches will be found). All returned family names are uppercase.

Resolve the substituted font family name for this family

The input must be upper case. The output will be the loaded font’s case. Example: SANS-SERIF

Add font aliases for family

When searching for family, all aliases will be searched too. Both the family parameter and all aliases are converted to upper case.

This method may only be used before initialization; if used afterwards, only a warning will be issued.

Control whether system fonts will be loaded on initialization

Default value: true

Loads a font data into the Database.

Will load all font faces in case of a font collection.

This method may only be used before initialization; if used afterwards, only a warning will be issued. By default, system fonts are loaded on initialization.

Loads a font file into the Database.

Will load all font faces in case of a font collection.

This method may only be used before initialization; if used afterwards, only a warning will be issued. By default, system fonts are loaded on initialization.

Loads font files from the selected directory into the Database.

This method will scan directories recursively.

Will load ttf, otf, ttc and otc fonts.

Unlike other load_* methods, this one doesn’t return an error. It will simply skip malformed fonts and will print a warning into the log for each of them.

This method may only be used before initialization; if used afterwards, only a warning will be issued. By default, system fonts are loaded on initialization.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Cast from Self to T Read more
Try converting from Self to T Read more
Try approximate conversion from Self to T Read more
Cast approximately from Self to T Read more
Cast to integer, truncating Read more
Cast to the nearest integer Read more
Cast the floor to an integer Read more
Cast the ceiling to an integer Read more
Try converting to integer with truncation Read more
Try converting to the nearest integer Read more
Try converting the floor to an integer Read more
Try convert the ceiling to an integer Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.