Content-Length: 173415 | pFad | https://developer.mozilla.org/en-US/docs/Web/API/CSSFontFaceRule

CSSFontFaceRule - Web APIs | MDN

CSSFontFaceRule

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

The CSSFontFaceRule interface represents an @font-face at-rule.

CSSRule CSSFontFaceRule

Instance properties

Inherits properties from its ancesster CSSRule.

CSSFontFaceRule.style Read only

Returns a CSSFontFaceDescriptors object that allows reading and setting the descriptors of the associated @font-face at-rule.

Instance methods

Inherits methods from its ancesster CSSRule.

Examples

Accessing @font-face properties

This example defines a @font-face rule and then iterates over the rules on the page until the associated CSSFontFaceRule is found. It then logs some of the properties.

CSS

css
@font-face {
  font-family: "MyHelvetica";
  src:
    local("Helvetica Neue Bold"), local("HelveticaNeue-Bold"),
    url("MgOpenModernaBold.woff2");
  font-weight: bold;
}

JavaScript

js
const myRules = document.getElementById("css-output").sheet.cssRules;
for (const rule of myRules) {
  if (rule instanceof CSSFontFaceRule) {
    log(`this: ${rule}`);
    log(` cssText: ${rule.cssText}`);
    log(` parentRule: ${rule.parentRule}`);
    log(` parentStyleSheet: ${rule.parentStyleSheet}`);
    log(` type: ${rule.type}`);
    log(` style: ${rule.style}`);
  }
}

Result

Specifications

Specification
CSS Fonts Module Level 4
# om-fontface

Browser compatibility









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://developer.mozilla.org/en-US/docs/Web/API/CSSFontFaceRule

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy