usvg

Struct FontResolver

source
pub struct FontResolver<'a> {
    pub select_font: FontSelectionFn<'a>,
    pub select_fallback: FallbackSelectionFn<'a>,
}
Expand description

A font resolver for <text> elements.

This type can be useful if you want to have an alternative font handling to the default one. By default, only fonts specified upfront in Options::fontdb will be used. This type allows you to load additional fonts on-demand and customize the font selection process.

Fields§

§select_font: FontSelectionFn<'a>

Resolver function that will be used when selecting a specific font for a generic Font specification.

§select_fallback: FallbackSelectionFn<'a>

Resolver function that will be used when selecting a fallback font for a character.

Implementations§

source§

impl FontResolver<'_>

source

pub fn default_font_selector() -> FontSelectionFn<'static>

Creates a default font selection resolver.

The default implementation forwards to query on the font database specified in the Options.

source

pub fn default_fallback_selector() -> FallbackSelectionFn<'static>

Creates a default font fallback selection resolver.

The default implementation searches through the entire fontdb to find a font that has the correct style and supports the character.

Trait Implementations§

source§

impl Debug for FontResolver<'_>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for FontResolver<'_>

source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<'a> Freeze for FontResolver<'a>

§

impl<'a> !RefUnwindSafe for FontResolver<'a>

§

impl<'a> Send for FontResolver<'a>

§

impl<'a> Sync for FontResolver<'a>

§

impl<'a> Unpin for FontResolver<'a>

§

impl<'a> !UnwindSafe for FontResolver<'a>

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.