Skip to main content
A newer version of this page is available. .

FontCollection Class

A collection of the Font objects.

Declaration

export class FontCollection extends Collection<Font>

Remarks

//reduces the document's font collection to the specified fonts
var myFonts = ['Arial', 'Calibri'];
richEdit.document.fonts.getAllFontNames().forEach(fontName => 
    myFonts.find(myFontName => 
        myFontName == fontName) ? null : richEdit.document.fonts.getByName(fontName).delete());

Inherited Members

Inheritance

Collection<T>
FontCollection

Methods

create(name) Method

Creates a new Font object with the specified settings and adds it to the collection.

Declaration

create(
    name: string,
    cssName?: string
): Font | null

Parameters

Name Type Description
name string

The font name.

cssName string

The CSS class name.

Returns

Type Description
Font

The newly created font.

null

The font creation failed.

Remarks

richEdit.document.fonts.create("myBeautyFont", "myFontCssClassName");

If a RichEdit font collection is specified on the server via the Fonts(Action<FontsSettingsBuilder>) method, the collection cannot be modified on the client side. The create method call failed and returns null.

getAllFontNames Method

Returns an array of font names available in the Rich Text Editor.

Declaration

getAllFontNames(): string[]

Returns

Type Description
string[]

An array of font names.

getByName(name) Method

Gets a font object specified by its name.

Declaration

getByName(
    name: string
): Font | null

Parameters

Name Type Description
name string

The font name.

Returns

Type Description
Font

A font with the specified name.

null

A font with the specified name is not found.