CSSFontFeatureValuesMap: set() Methode
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Die set() Methode von CSSFontFeatureValuesMap-Instanzen fügt einen neuen Eintrag mit einem angegebenen Schlüssel und Wert zu dieser CSSFontFeatureValuesMap hinzu, oder aktualisiert einen bestehenden Eintrag, wenn der Schlüssel bereits existiert.
Syntax
set(key, value)
Parameter
key-
Der Schlüssel des Eintrags, der in das
CSSFontFeatureValuesMap-Objekt hinzugefügt oder geändert werden soll. Kann einen beliebigen Wert haben. value-
Der Wert des Eintrags, der in das
CSSFontFeatureValuesMap-Objekt hinzugefügt oder geändert werden soll. Muss eine ganze Zahl sein, die demindexdes alternativen Schriftmerkmals entspricht.
Rückgabewert
Das CSSFontFeatureValuesMap-Objekt.
Beispiele
>Grundlegende Nutzung
Im folgenden Beispiel wird der Wert für swashy aktualisiert und eine dritte Deklaration hinzugefügt. Dieses Beispiel verwendet @swash, funktioniert aber auch mit anderen Feature-Werte-Blöcken.
CSS
@font-feature-values "MonteCarlo" {
@swash {
swishy: 1;
swashy: 2;
}
}
JavaScript
function logSwashes(value, key) {
console.log(`('${key}') = ${value}`);
}
// get the rules
const myRule = document.styleSheets[0].cssRules[0];
// log current swashes
myRule.swash.forEach(logSwashes); // logs "('swishy') = 1", "('swashy') = 2"
// update swash with the key swashy
myRule.swash.set("swashy", 3);
myRule.swash.forEach(logSwashes); // logs "('swishy') = 1", "('swashy') = 3"
// add new swash with the key swooshy
myRule.swash.set("swooshy", 2);
myRule.swash.forEach(logSwashes); // logs "('swishy') = 1", "('swooshy') = 2", "('swashy') = 3"
Spezifikationen
| Specification |
|---|
| CSS Fonts Module Level 4> # dom-cssfontfeaturevaluesmap-set> |