CSSFontFeatureValuesRule: Eigenschaft fontFamily
Baseline
2025
Neu verfügbar
Seit March 2025 funktioniert diese Funktion auf aktuellen Geräten und in aktuellen Browserversionen. Auf älteren Geräten oder in älteren Browsern funktioniert sie möglicherweise nicht.
Die fontFamily-Eigenschaft der Schnittstelle CSSFontFeatureValuesRule repräsentiert den Namen der Schriftfamilie, auf die sie angewendet wird.
Wert
Ein Zeichenkette.
Beispiele
>Schriftfamilie auslesen
In diesem Beispiel deklarieren wir zwei @font-feature-values, eine für die Font One Schriftfamilie und die andere für Font Two. Wir verwenden dann das CSSOM, um diese Schriftfamilien auszulesen und in das Logbuch anzuzeigen.
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.getElementById("css-output").sheet.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
| Spezifikation |
|---|
| CSS Fonts Module Level 4> # dom-cssfontfeaturevaluesrule-fontfamily> |