Table of Contents

Class FontManager

Namespace
Avalonia.Media
Assembly
Avalonia.Base.dll

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.

public sealed class FontManager
Inheritance
FontManager
Inherited Members

Constructors

FontManager(IFontManagerImpl)

public FontManager(IFontManagerImpl platformImpl)

Parameters

platformImpl IFontManagerImpl

Fields

CompositeFontScheme

public const string CompositeFontScheme = "compositefont"

Field Value

string

FontCollectionScheme

public const string FontCollectionScheme = "fonts"

Field Value

string

SystemFontScheme

public const string SystemFontScheme = "systemfont"

Field Value

string

Properties

Current

Get the current font manager instance.

public static FontManager Current { get; }

Property Value

FontManager

DefaultFontFamily

Gets the system's default font family.

public FontFamily DefaultFontFamily { get; }

Property Value

FontFamily

SystemFonts

Get all system fonts.

public IFontCollection SystemFonts { get; }

Property Value

IFontCollection

Methods

AddFontCollection(IFontCollection)

Add a font collection to the manager.

public void AddFontCollection(IFontCollection fontCollection)

Parameters

fontCollection IFontCollection

The font collection.

Remarks

If a font collection's key is already present the collection is replaced.

Exceptions

ArgumentException

RemoveFontCollection(Uri)

Removes the font collection that corresponds to specified key.

public void RemoveFontCollection(Uri key)

Parameters

key Uri

The font collection's key.

TryGetGlyphTypeface(Typeface, out IGlyphTypeface?)

Tries to get a glyph typeface for specified typeface.

public bool TryGetGlyphTypeface(Typeface typeface, out IGlyphTypeface? glyphTypeface)

Parameters

typeface Typeface

The typeface.

glyphTypeface IGlyphTypeface

The created glyphTypeface

Returns

bool

True, if the FontManager could create the glyph typeface, False otherwise.

TryMatchCharacter(int, FontStyle, FontWeight, FontStretch, FontFamily?, CultureInfo?, out Typeface)

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

public bool TryMatchCharacter(int codepoint, FontStyle fontStyle, FontWeight fontWeight, FontStretch fontStretch, FontFamily? fontFamily, CultureInfo? culture, out Typeface typeface)

Parameters

codepoint int

The codepoint to match against.

fontStyle FontStyle

The font style.

fontWeight FontWeight

The font weight.

fontStretch FontStretch

The font stretch.

fontFamily FontFamily

The font family. This is optional and used for fallback lookup.

culture CultureInfo

The culture.

typeface Typeface

The matching Typeface.

Returns

bool

True, if the FontManager could match the character to specified parameters, False otherwise.