CSSFontFeatureValuesRule

Baseline 2023 *
Newly available

Since March 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

* Some parts of this feature may have varying levels of support.

Das CSSFontFeatureValuesRule-Interface repräsentiert eine @font-feature-values at-rule, die es Entwicklern ermöglicht, für jede Schriftart einen gemeinsamen Namen zuzuweisen, um Indizes für Features zu spezifizieren, die in font-variant-alternates verwendet werden sollen.

CSSRule CSSFontFeatureValuesRule

Instanz-Eigenschaften

Erbt Eigenschaften von seinem Vorfahren CSSRule.

CSSFontFeatureValuesRule.fontFamily

Ein String, der die Schriftfamilie identifiziert, auf die diese Regel angewendet wird.

Instanz-Methoden

Erbt Methoden von seinem Vorfahren CSSRule.

Beispiele

Schriftfamilie auslesen

In diesem Beispiel deklarieren wir zwei @font-feature-values, eine für die Schriftfamilie Font One und eine andere für Font Two. Anschließend verwenden wir das CSSOM, um diese Schriftfamilien auszulesen und sie im Log anzuzeigen.

HTML

html
<pre id="log"></pre>

CSS

css
/* At-rule for "nice-style" in Font One */
@font-feature-values Font One {
  @styleset {
    nice-style: 12;
  }
}

/* At-rule for "nice-style" in Font Two */
@font-feature-values Font Two {
  @styleset {
    nice-style: 4;
  }
}

/* Apply the at-rules with a single declaration */
.nice-look {
  font-variant-alternates: styleset(nice-style);
}

JavaScript

js
const log = document.getElementById("log");
const rules = document.styleSheets[document.styleSheets.length - 1].cssRules;

const fontOne = rules[0]; // A CSSFontFeatureValuesRule
log.textContent = `The 1st '@font-feature-values' family: "${fontOne.fontFamily}".\n`;

const fontTwo = rules[1]; // Another CSSFontFeatureValuesRule
log.textContent += `The 2nd '@font-feature-values' family: "${fontTwo.fontFamily}".`;

Spezifikationen

Specification
CSS Fonts Module Level 4
# cssfontfeaturevaluesrule

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
CSSFontFeatureValuesRule
annotation
Experimental
characterVariant
Experimental
fontFamily
ornaments
Experimental
styleset
Experimental
stylistic
Experimental
swash
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.

Siehe auch