interface

FontFace — CSS reference

Represents a single usable font face. Construct it from a CSS source string or font buffer; load returns a promise, and adding the face to document.fonts makes it available for document matching. Load rejection must be handled.

Formal Syntax & Structure

css syntaxcss
new FontFace(family, source, descriptors?); face.load();

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS font lab</title><style>body {margin:0} .sample {background:#dcebe9;color:#182e32} #a{font-family:LabProgram,sans-serif}</style><body><p id="a">Office 012345 — typography</p><p id="b" lang="fa" dir="rtl">سلام دنیا</p><script>const face = new FontFace("LabProgram", "local(\"DejaVu Sans\")"); document.fonts.add(face); window.loaded = face.load().then(()=>true,()=>false);</script></body></html>
CSS Reference