web api instance method
FontFaceSet: add() method
Available in workers
The add() method of the FontFaceSet interface adds a new font to the set.
Syntax
add(font)
Parameters
font- : A
FontFaceto be added to the set.
- : A
Return value
A new FontFaceSet.
Exceptions
InvalidModificationErrorDOMException- : Thrown if this font is already included via the CSS
@font-facerule.
- : Thrown if this font is already included via the CSS
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);
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.