Type Alias usvg::FontSelectionFn
source · pub type FontSelectionFn<'a> = Box<dyn Fn(&Font, &mut Arc<Database>) -> Option<ID> + Send + Sync + 'a>;
Expand description
A shorthand for FontResolver’s font selection function.
This function receives a font specification (families + a style, weight, stretch triple) and a font database and should return the ID of the font that shall be used (if any).
In the basic case, the function will search the existing fonts in the
database to find a good match, e.g. via
Database::query
. This is what the default
implementation does.
Users with more complex requirements can mutate the database to load
additional fonts dynamically. To perform mutation, it is recommended to call
Arc::make_mut
on the provided database. (This call is not done outside of
the callback to not needless clone an underlying shared database if no
mutation will be performed.) It is important that the database is only
mutated additively. Removing fonts or replacing the entire database will
break things.
Aliased Type§
struct FontSelectionFn<'a>(/* private fields */);