Table of Contents

Class FontCollection

Namespace
SixLabors.Fonts
Assembly
SixLabors.Fonts.dll

Represents a collection of font families.

public sealed class FontCollection : IFontCollection, IReadOnlyFontCollection
Inheritance
FontCollection
Implements
Inherited Members
Extension Methods

Constructors

FontCollection()

Initializes a new instance of the FontCollection class.

public FontCollection()

Properties

Families

Gets the collection of FontFamily in this IReadOnlyFontCollection using the invariant culture.

public IEnumerable<FontFamily> Families { get; }

Property Value

IEnumerable<FontFamily>

Methods

Add(Stream)

Adds a font to the collection.

public FontFamily Add(Stream stream)

Parameters

stream Stream

The font stream.

Returns

FontFamily

The new FontFamily.

Add(Stream, out FontDescription)

Adds a font to the collection.

public FontFamily Add(Stream stream, out FontDescription description)

Parameters

stream Stream

The font stream.

description FontDescription

The description of the added font.

Returns

FontFamily

The new FontFamily.

Add(string)

Adds a font to the collection.

public FontFamily Add(string path)

Parameters

path string

The filesystem path to the font file.

Returns

FontFamily

The new FontFamily.

Add(string, out FontDescription)

Adds a font to the collection.

public FontFamily Add(string path, out FontDescription description)

Parameters

path string

The filesystem path to the font file.

description FontDescription

The description of the added font.

Returns

FontFamily

The new FontFamily.

AddCollection(Stream)

Adds a true type font collection (.ttc).

public ReadOnlyMemory<FontFamily> AddCollection(Stream stream)

Parameters

stream Stream

The font stream.

Returns

ReadOnlyMemory<FontFamily>

A read-only memory region containing the new FontFamily values.

AddCollection(Stream, CultureInfo)

Adds a true type font collection (.ttc).

public ReadOnlyMemory<FontFamily> AddCollection(Stream stream, CultureInfo culture)

Parameters

stream Stream

The font stream.

culture CultureInfo

The culture of the fonts to add.

Returns

ReadOnlyMemory<FontFamily>

A read-only memory region containing the new FontFamily values.

AddCollection(Stream, CultureInfo, out ReadOnlyMemory<FontDescription>)

Adds a true type font collection (.ttc).

public ReadOnlyMemory<FontFamily> AddCollection(Stream stream, CultureInfo culture, out ReadOnlyMemory<FontDescription> descriptions)

Parameters

stream Stream

The font stream.

culture CultureInfo

The culture of the fonts to add.

descriptions ReadOnlyMemory<FontDescription>

The descriptions of the added fonts.

Returns

ReadOnlyMemory<FontFamily>

A read-only memory region containing the new FontFamily values.

AddCollection(Stream, out ReadOnlyMemory<FontDescription>)

Adds a true type font collection (.ttc).

public ReadOnlyMemory<FontFamily> AddCollection(Stream stream, out ReadOnlyMemory<FontDescription> descriptions)

Parameters

stream Stream

The font stream.

descriptions ReadOnlyMemory<FontDescription>

The descriptions of the added fonts.

Returns

ReadOnlyMemory<FontFamily>

A read-only memory region containing the new FontFamily values.

AddCollection(string)

Adds a true type font collection (.ttc).

public ReadOnlyMemory<FontFamily> AddCollection(string path)

Parameters

path string

The font collection path.

Returns

ReadOnlyMemory<FontFamily>

A read-only memory region containing the new FontFamily values.

AddCollection(string, CultureInfo)

Adds a true type font collection (.ttc).

public ReadOnlyMemory<FontFamily> AddCollection(string path, CultureInfo culture)

Parameters

path string

The font collection path.

culture CultureInfo

The culture of the fonts to add.

Returns

ReadOnlyMemory<FontFamily>

A read-only memory region containing the new FontFamily values.

AddCollection(string, CultureInfo, out ReadOnlyMemory<FontDescription>)

Adds a true type font collection (.ttc).

public ReadOnlyMemory<FontFamily> AddCollection(string path, CultureInfo culture, out ReadOnlyMemory<FontDescription> descriptions)

Parameters

path string

The font collection path.

culture CultureInfo

The culture of the fonts to add.

descriptions ReadOnlyMemory<FontDescription>

The descriptions of the added fonts.

Returns

ReadOnlyMemory<FontFamily>

A read-only memory region containing the new FontFamily values.

AddCollection(string, out ReadOnlyMemory<FontDescription>)

Adds a true type font collection (.ttc).

public ReadOnlyMemory<FontFamily> AddCollection(string path, out ReadOnlyMemory<FontDescription> descriptions)

Parameters

path string

The font collection path.

descriptions ReadOnlyMemory<FontDescription>

The descriptions of the added fonts.

Returns

ReadOnlyMemory<FontFamily>

A read-only memory region containing the new FontFamily values.

AddWithCulture(Stream, CultureInfo)

Adds a font to the collection.

public FontFamily AddWithCulture(Stream stream, CultureInfo culture)

Parameters

stream Stream

The font stream.

culture CultureInfo

The culture of the font to add.

Returns

FontFamily

The new FontFamily.

AddWithCulture(Stream, CultureInfo, out FontDescription)

Adds a font to the collection.

public FontFamily AddWithCulture(Stream stream, CultureInfo culture, out FontDescription description)

Parameters

stream Stream

The font stream.

culture CultureInfo

The culture of the font to add.

description FontDescription

The description of the added font.

Returns

FontFamily

The new FontFamily.

AddWithCulture(string, CultureInfo)

Adds a font to the collection.

public FontFamily AddWithCulture(string path, CultureInfo culture)

Parameters

path string

The filesystem path to the font file.

culture CultureInfo

The culture of the font to add.

Returns

FontFamily

The new FontFamily.

AddWithCulture(string, CultureInfo, out FontDescription)

Adds a font to the collection.

public FontFamily AddWithCulture(string path, CultureInfo culture, out FontDescription description)

Parameters

path string

The filesystem path to the font file.

culture CultureInfo

The culture of the font to add.

description FontDescription

The description of the added font.

Returns

FontFamily

The new FontFamily.

Get(string)

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

public 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 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 FontFamily GetByCulture(string name, CultureInfo culture)

Parameters

name string

The font family name.

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.

TryGet(string, out FontFamily)

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

public bool TryGet(string name, out FontFamily family)

Parameters

name string

The font family name.

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 bool TryGetByCulture(string name, CultureInfo culture, out FontFamily family)

Parameters

name string

The font family name.

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