Table of Contents

Class SystemFonts

Namespace
SixLabors.Fonts
Assembly
SixLabors.Fonts.dll

Provides a collection of fonts.

public static class SystemFonts
Inheritance
SystemFonts
Inherited Members

Properties

Collection

Gets the collection containing the globally installed system fonts.

public static IReadOnlySystemFontCollection Collection { get; }

Property Value

IReadOnlySystemFontCollection

FallbackResolver

Gets a resolver that selects fallback font families from the installed system fonts. Assign it to FontFallbackResolver to let shaping consult the operating system for code points no configured font can shape.

public static IFontFallbackResolver FallbackResolver { get; }

Property Value

IFontFallbackResolver

Families

Gets the collection of FontFamilys installed on current system.

public static IEnumerable<FontFamily> Families { get; }

Property Value

IEnumerable<FontFamily>

Methods

CreateFont(string, CultureInfo, float)

Create a new instance of the Font for the named font family with regular styling.

public static Font CreateFont(string name, CultureInfo culture, float size)

Parameters

name string

The font family name.

culture CultureInfo

The font culture.

size float

The size of the font in PT units.

Returns

Font

The new Font.

CreateFont(string, CultureInfo, float, FontStyle)

Create a new instance of the Font for the named font family.

public static Font CreateFont(string name, CultureInfo culture, float size, FontStyle style)

Parameters

name string

The font family name.

culture CultureInfo

The font culture.

size float

The size of the font in PT units.

style FontStyle

The font style.

Returns

Font

The new Font.

CreateFont(string, float)

Create a new instance of the Font for the named font family with regular styling.

public static Font CreateFont(string name, float size)

Parameters

name string

The font family name.

size float

The size of the font in PT units.

Returns

Font

The new Font.

CreateFont(string, float, FontStyle)

Create a new instance of the Font for the named font family.

public static Font CreateFont(string name, float size, FontStyle style)

Parameters

name string

The font family name.

size float

The size of the font in PT units.

style FontStyle

The font style.

Returns

Font

The new Font.

Get(string)

Gets the specified font family matching the invariant culture and font family name.

public static FontFamily Get(string name)

Parameters

name string

The font family name.

Returns

FontFamily

The first FontFamily matching the given name.

Exceptions

ArgumentNullException

name is null

FontFamilyNotFoundException

The collection contains no matches.

GetByCulture(CultureInfo)

Gets the collection of FontFamily in this FontCollection using the given culture.

public static IEnumerable<FontFamily> GetByCulture(CultureInfo culture)

Parameters

culture CultureInfo

The culture of the families to return.

Returns

IEnumerable<FontFamily>

The IEnumerable<T>.

GetByCulture(string, CultureInfo)

Gets the specified font family matching the given culture and font family name.

public static FontFamily GetByCulture(string fontFamily, CultureInfo culture)

Parameters

fontFamily string
culture CultureInfo

The culture to use when searching for a match.

Returns

FontFamily

The first FontFamily matching the given name.

Exceptions

ArgumentNullException

name is null

FontFamilyNotFoundException

The collection contains no matches.

GetDefaultFamilyName()

Gets the operating system default font family name.

public static string GetDefaultFamilyName()

Returns

string

The default font family name.

Exceptions

InvalidOperationException

No system font families are available.

GetFamilyNames(bool)

Gets the names of font families installed on current system.

public static string[] GetFamilyNames(bool checkForUpdates = false)

Parameters

checkForUpdates bool

Whether the operating system should check for updates to the system font collection.

Returns

string[]

The installed system font family names.

TryGet(string, out FontFamily)

Gets the specified font family matching the invariant culture and font family name.

public static bool TryGet(string fontFamily, out FontFamily family)

Parameters

fontFamily string
family FontFamily

When this method returns, contains the family associated with the specified name, if the name is found; otherwise, the default value for the type of the family parameter. This parameter is passed uninitialized.

Returns

bool

true if the IReadOnlyFontCollection contains a family with the specified name; otherwise, false.

Exceptions

ArgumentNullException

name is null

TryGetByCulture(string, CultureInfo, out FontFamily)

Gets the specified font family matching the given culture and font family name.

public static bool TryGetByCulture(string fontFamily, CultureInfo culture, out FontFamily family)

Parameters

fontFamily string
culture CultureInfo

The culture to use when searching for a match.

family FontFamily

When this method returns, contains the family associated with the specified name, if the name is found; otherwise, the default value for the type of the family parameter. This parameter is passed uninitialized.

Returns

bool

true if the IReadOnlyFontCollection contains a family with the specified name; otherwise, false.

Exceptions

ArgumentNullException

name is null

TryGetDefaultFamilyName(out string?)

Tries to get the operating system default font family name.

public static bool TryGetDefaultFamilyName(out string? familyName)

Parameters

familyName string

The operating system default font family name.

Returns

bool

true when the operating system returned a default font family name.

TryMatchCharacter(CodePoint, FontStyle, string?, CultureInfo?, out FontMatch)

Tries to match a character to an installed system font.

public static bool TryMatchCharacter(CodePoint codePoint, FontStyle style, string? familyName, CultureInfo? culture, out FontMatch match)

Parameters

codePoint CodePoint

The code point to match.

style FontStyle

The requested font style.

familyName string

The requested font family name, or null.

culture CultureInfo

The culture used for matching, or null.

match FontMatch

When this method returns, contains the matched font if one was found; otherwise, the default value. This parameter is passed uninitialized.

Returns

bool

true if a matching system font was found; otherwise, false.