Skip to main content

FontFaceSet

The FontFaceSet interface of the CSS Font Loading API manages the loading of font-faces and querying of their download status.

MDN Reference

Extends​

Methods​

[iterator]()​

iterator: SetIterator<FontFace>;

Iterates over values in the set.

Returns​

SetIterator<FontFace>


add()​

add(value): this;

Appends a new element with a specified value to the end of the Set.

Parameters​

ParameterType
valueFontFace

Returns​

this


addEventListener()​

Call Signature​

addEventListener<K>(
type,
listener,
options?
): void;

The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

MDN Reference

Type Parameters​
Type Parameter
K extends keyof FontFaceSetEventMap
Parameters​
ParameterType
typeK
listener(this, ev) => any
options?boolean | AddEventListenerOptions
Returns​

void

Overrides​

EventTarget.addEventListener

Call Signature​

addEventListener(
type,
listener,
options?
): void;

The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

MDN Reference

Parameters​
ParameterType
typestring
listenerEventListenerOrEventListenerObject
options?boolean | AddEventListenerOptions
Returns​

void

Overrides​
EventTarget.addEventListener

check()​

check(font, text?): boolean;

The check() method of the FontFaceSet returns true if you can render some text using the given font specification without attempting to use any fonts in this FontFaceSet that are not yet fully loaded. This means you can use the font specification without causing a font swap.

MDN Reference

Parameters​

ParameterType
fontstring
text?string

Returns​

boolean


clear()​

clear(): void;

Removes all elements from the Set.

Returns​

void


delete()​

delete(value): boolean;

Removes a specified value from the Set.

Parameters​

ParameterType
valueFontFace

Returns​

boolean

Returns true if an element in the Set existed and has been removed, or false if the element does not exist.


dispatchEvent()​

dispatchEvent(event): boolean;

The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().

MDN Reference

Parameters​

ParameterType
eventEvent

Returns​

boolean

Inherited from​

EventTarget.dispatchEvent


entries()​

entries(): SetIterator<[FontFace, FontFace]>;

Returns an iterable of [v,v] pairs for every value v in the set.

Returns​

SetIterator<[FontFace, FontFace]>


forEach()​

forEach(callbackfn, thisArg?): void;

Parameters​

ParameterType
callbackfn(value, key, parent) => void
thisArg?any

Returns​

void


has()​

has(value): boolean;

Parameters​

ParameterType
valueFontFace

Returns​

boolean

a boolean indicating whether an element with the specified value exists in the Set or not.


keys()​

keys(): SetIterator<FontFace>;

Despite its name, returns an iterable of the values in the set.

Returns​

SetIterator<FontFace>


load()​

load(font, text?): Promise<FontFace[]>;

The load() method of the FontFaceSet forces all the fonts given in parameters to be loaded.

MDN Reference

Parameters​

ParameterType
fontstring
text?string

Returns​

Promise<FontFace[]>


removeEventListener()​

Call Signature​

removeEventListener<K>(
type,
listener,
options?
): void;

The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

MDN Reference

Type Parameters​
Type Parameter
K extends keyof FontFaceSetEventMap
Parameters​
ParameterType
typeK
listener(this, ev) => any
options?boolean | EventListenerOptions
Returns​

void

Overrides​

EventTarget.removeEventListener

Call Signature​

removeEventListener(
type,
listener,
options?
): void;

The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.

MDN Reference

Parameters​
ParameterType
typestring
listenerEventListenerOrEventListenerObject
options?boolean | EventListenerOptions
Returns​

void

Overrides​
EventTarget.removeEventListener

values()​

values(): SetIterator<FontFace>;

Returns an iterable of values in the set.

Returns​

SetIterator<FontFace>

Properties​

[toStringTag]​

readonly [toStringTag]: string;

onloading​

onloading: ((this, ev) => any) | null;

MDN Reference


onloadingdone​

onloadingdone: ((this, ev) => any) | null;

MDN Reference


onloadingerror​

onloadingerror: ((this, ev) => any) | null;

MDN Reference


ready​

readonly ready: Promise<FontFaceSet>;

The ready read-only property of the FontFaceSet interface returns a Promise that resolves to the given FontFaceSet.

MDN Reference


size​

readonly size: number;

Returns​

the number of (unique) elements in Set.


status​

readonly status: FontFaceSetLoadStatus;

The status read-only property of the FontFaceSet interface returns the loading state of the fonts in the set.

MDN Reference