Firefox Tomorrow

web api instance method

FontFaceSet: add() method

View on MDN ↗

Available in workers

The add() method of the FontFaceSet interface adds a new font to the set.

Syntax

add(font)

Parameters

  • font

Return value

A new FontFaceSet.

Exceptions

  • InvalidModificationError DOMException
    • : 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);

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.