# FontManager

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/media/struct-fontmanager/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct FontManager
```

The font manager is used to query the system's installed fonts and is
responsible for caching loaded fonts. It is also responsible for the font
fallback.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/font_manager.rs#L26)

## Members

- [`FONT_COLLECTION_SCHEME`](#assoc_const-font_collection_scheme)
- [`SYSTEM_FONT_SCHEME`](#assoc_const-system_font_scheme)
- [`COMPOSITE_FONT_SCHEME`](#assoc_const-composite_font_scheme)
- [`system_fonts_key`](#function-system_fonts_key)
- [`current`](#function-current)
- [`default_font_family`](#function-default_font_family)
- [`system_fonts`](#function-system_fonts)
- [`try_get_glyph_typeface`](#function-try_get_glyph_typeface)
- [`invalidate_glyph_typefaces`](#function-invalidate_glyph_typefaces)
- [`add_font_collection`](#function-add_font_collection)
- [`remove_font_collection`](#function-remove_font_collection)
- [`try_match_character`](#function-try_match_character)
- [`get_family_typefaces`](#function-get_family_typefaces)
- [`dispose`](#function-dispose)

<a id="assoc_const-font_collection_scheme"></a>

### FONT_COLLECTION_SCHEME

```rust
const FONT_COLLECTION_SCHEME: &'static str
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/font_manager.rs#L74)

<a id="assoc_const-system_font_scheme"></a>

### SYSTEM_FONT_SCHEME

```rust
const SYSTEM_FONT_SCHEME: &'static str
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/font_manager.rs#L75)

<a id="assoc_const-composite_font_scheme"></a>

### COMPOSITE_FONT_SCHEME

```rust
const COMPOSITE_FONT_SCHEME: &'static str
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/font_manager.rs#L76)

<a id="function-system_fonts_key"></a>

### system_fonts_key

```rust
fn system_fonts_key() -> url::Url
```

The key of the system font collection (`fonts:SystemFonts`).

Internal upstream, where the Skia unit tests see it; public here so
that the tests of the Skia crate reach it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/font_manager.rs#L85)

<a id="function-current"></a>

### current

```rust
fn current() -> Rc<FontManager>
```

Get the current font manager instance.

The font manager registered with the locator, or a new one created on
top of the registered font backend (and then registered).

Panics when no font backend (`IFontManagerImpl`) is registered.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/font_manager.rs#L163)

<a id="function-default_font_family"></a>

### default_font_family

```rust
fn default_font_family(self: &Self) -> &FontFamily
```

Gets the system's default font family.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/font_manager.rs#L183)

<a id="function-system_fonts"></a>

### system_fonts

```rust
fn system_fonts(self: &Self) -> Rc<dyn IFontCollection>
```

Get all system fonts.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/font_manager.rs#L188)

<a id="function-try_get_glyph_typeface"></a>

### try_get_glyph_typeface

```rust
fn try_get_glyph_typeface(self: &Self, typeface: &Typeface) -> Option<Rc<GlyphTypeface>>
```

Tries to get a glyph typeface for specified typeface.

Returns the glyph typeface if the font manager could create it,
`None` otherwise.

The glyph typeface found for a typeface is kept until a font collection gains a glyph
typeface or a collection is added or removed; a collection that does not derive from
`FontCollectionBase` and changes what it returns
calls `invalidate_glyph_typefaces`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/font_manager.rs#L214)

<a id="function-invalidate_glyph_typefaces"></a>

### invalidate_glyph_typefaces

```rust
fn invalidate_glyph_typefaces(self: &Self)
```

Makes this font manager look every glyph typeface up again: for a font collection that
does not derive from `FontCollectionBase` and whose glyph typefaces changed.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/font_manager.rs#L235)

<a id="function-add_font_collection"></a>

### add_font_collection

```rust
fn add_font_collection(self: &Self, font_collection: Rc<dyn IFontCollection>)
```

Add a font collection to the manager.

If a font collection's key is already present the collection is
replaced (and the replaced collection disposed).

Panics when the key of the collection does not follow the `fonts:` scheme.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/font_manager.rs#L382)

<a id="function-remove_font_collection"></a>

### remove_font_collection

```rust
fn remove_font_collection(self: &Self, key: &url::Url)
```

Removes the font collection that corresponds to specified key.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/font_manager.rs#L400)

<a id="function-try_match_character"></a>

### try_match_character

```rust
fn try_match_character(self: &Self, codepoint: i32, font_style: FontStyle, font_weight: FontWeight, font_stretch: FontStretch, font_family: Option<&FontFamily>, culture: Option<&Locale>) -> Option<Typeface>
```

Tries to match a specified character to a `Typeface` that supports
specified font properties.

`font_family` is optional and used for fallback lookup.

Returns the matching typeface if the font manager could match the
character to specified parameters, `None` otherwise.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/font_manager.rs#L416)

<a id="function-get_family_typefaces"></a>

### get_family_typefaces

```rust
fn get_family_typefaces(self: &Self, font_family: &FontFamily) -> Vec<Typeface>
```

The typefaces of a font family; empty when the family is unknown.

Internal upstream, where the Skia unit tests see it; public here so
that the tests of the Skia crate reach it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/font_manager.rs#L581)

<a id="function-dispose"></a>

### dispose

```rust
fn dispose(self: &Self)
```

Disposes every font collection and the font backend.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/media/font_manager.rs#L688)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ErasedDestructor`
- `IntoEither`
- `PartialEq`
- [`MarkupTyped`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)
- [`ValueTypeRegistration`](/docs/0.5.0/api/ferroui-base/data/core/trait-valuetyperegistration/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
