FontFaceSet
The FontFaceSet interface of the CSS Font Loading API manages the loading of font-faces and querying of their download status.
Extends
EventTarget.Set<FontFace>
Methods
[iterator]()
iterator: SetIterator<FontFace>;
Iterates over values in the set.
Returns
add()
add(value): this;
Appends a new element with a specified value to the end of the Set.
Parameters
| Parameter | Type |
|---|---|
value | FontFace |
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.
Type Parameters
| Type Parameter |
|---|
K extends keyof FontFaceSetEventMap |
Parameters
| Parameter | Type |
|---|---|
type | K |
listener | (this, ev) => any |
options? | boolean | AddEventListenerOptions |
Returns
void
Overrides
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.
Parameters
| Parameter | Type |
|---|---|
type | string |
listener | EventListenerOrEventListenerObject |
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.
Parameters
| Parameter | Type |
|---|---|
font | string |
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
| Parameter | Type |
|---|---|
value | FontFace |
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().
Parameters
| Parameter | Type |
|---|---|
event | Event |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
callbackfn | (value, key, parent) => void |
thisArg? | any |
Returns
void
has()
has(value): boolean;
Parameters
| Parameter | Type |
|---|---|
value | FontFace |
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
load()
load(font, text?): Promise<FontFace[]>;
The load() method of the FontFaceSet forces all the fonts given in parameters to be loaded.
Parameters
| Parameter | Type |
|---|---|
font | string |
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.
Type Parameters
| Type Parameter |
|---|
K extends keyof FontFaceSetEventMap |
Parameters
| Parameter | Type |
|---|---|
type | K |
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.
Parameters
| Parameter | Type |
|---|---|
type | string |
listener | EventListenerOrEventListenerObject |
options? | boolean | EventListenerOptions |
Returns
void
Overrides
EventTarget.removeEventListener
values()
values(): SetIterator<FontFace>;
Returns an iterable of values in the set.
Returns
Properties
[toStringTag]
readonly [toStringTag]: string;
onloading
onloading: ((this, ev) => any) | null;
onloadingdone
onloadingdone: ((this, ev) => any) | null;
onloadingerror
onloadingerror: ((this, ev) => any) | null;
ready
readonly ready: Promise<FontFaceSet>;
The ready read-only property of the FontFaceSet interface returns a Promise that resolves to the given FontFaceSet.
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.