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

Parameters

Name Type Description
name string

The font name.

cssName string

The CSS class name.

Returns

Type Description
Font

The newly created font.

Remarks

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

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.