FontFaceSet: add() method
CSS Font Loading API
CSS Font Loading API
The add() method of the FontFaceSet interface adds a new font to the set.
Syntax
add(font)
Parameters
font- : A FontFace to be added to the set.
Return value
A new FontFaceSet.
Exceptions
InvalidModificationErrorDOMException- : Thrown if this font is already included via the CSS @font-face rule.
Examples
In the following example a new FontFace object is created and then added to the FontFaceSet.
const font = new FontFace("MyFont", 'url("myFont.woff2")');
document.fonts.add(font);