Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

FontCollection Class

A collection of the Font objects.

#Declaration

TypeScript
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

TypeScript
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 if 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

TypeScript
getAllFontNames(): string[]

#Returns

Type Description
string[]

An array of font names.

#getByName(name) Method

Gets a font object specified by its name.

#Declaration

TypeScript
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 if a font with the specified name is not found.