Back to Devexpress

FontCollection Class

aspnetcore-js-devexpress-dot-richedit-27e1f153.md

latest2.6 KB
Original Source

FontCollection Class

A collection of the Font objects.

Declaration

ts
export class FontCollection extends Collection<Font>

Remarks

javascript
//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

count

getByIndex(index)

Inheritance

Collection<T> FontCollection

Methods

create(name) Method

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

Declaration

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

Parameters

NameTypeDescription
namestring

The font name.

| | cssName | string |

The CSS class name.

|

Returns

TypeDescription
Font

The newly created font. null if the font creation failed.

|

Remarks

javascript
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

ts
getAllFontNames(): string[]

Returns

TypeDescription
string[]

An array of font names.

|

getByName(name) Method

Gets a font object specified by its name.

Declaration

ts
getByName(
    name: string
): Font | null

Parameters

NameTypeDescription
namestring

The font name.

|

Returns

TypeDescription
Font

A font with the specified name. null if a font with the specified name is not found.

|