@font-feature-values
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.
概要
@font-feature-values
CSS at-rule 允许作者在font-variant-alternates
中使用通用名称,用于在 OpenType 中以不同方式激活功能。它允许在使用几种字体时简化 CSS。
@font-feature-values Font One {
/* How to activate nice-style in Font One */
@styleset {
nice-style: 12;
}
}
@font-feature-values Font Two {
/* How to activate nice-style in Font Two */
@styleset {
nice-style: 4;
}
}
/* … */
.nice-look {
font-variant-alternates: styleset(nice-style);
} /* Independent of the font */
The @font-feature-values
at-rule may be used at the top level of a CSS, but also inside any CSS conditional-group at-rule.
Syntax
Feature value blocks
@swash
-
Specifies a feature name that will work with the
swash()
functional notation offont-variant-alternates
. A swash feature value definition allows only one value:ident1: 2
is valid whenident2: 2 4
isn't. @annotation
-
Specifies a feature name that will work with the
annotation()
functional notation offont-variant-alternates
. An annotation feature value definition allows only one value:ident1: 2
is valid whenident2: 2 4
isn't. @ornaments
-
Specifies a feature name that will work with the
ornaments()
functional notation offont-variant-alternates
. An ornaments feature value definition allows only one value:ident1: 2
is valid whenident2: 2 4
isn't. @stylistic
-
Specifies a feature name that will work with the
stylistic()
functional notation offont-variant-alternates
. A stylistice feature value definition allows only one value:ident1: 2
is valid whenident2: 2 4
isn't. @styleset
-
Specifies a feature name that will work with the
styleset()
functional notation offont-variant-alternates
. A stylset feature value definition allows and illimited amount of values:ident1: 2 4 12 1
maps to the OpenType valuesss02
,ss04
,ss12
,ss01
. Note that values higher than99
are valid, but doesn't map to any OpenType values and are ignored. @character-variant
-
Specifies a feature name that will work with the
character-variant()
functional notation offont-variant-alternates
. A character-variant feature value definition allows one or two values:ident1: 2
maps tocv02=1
andident2: 2 4
maps tocv02)4
andident2: 2 4 5
isn't valid.
Formal syntax
@font-feature-values =
@font-feature-values <family-name># { <declaration-rule-list> }
<family-name> =
<string> |
<custom-ident>+
Specifications
Specification |
---|
CSS Fonts Module Level 4 # font-feature-values |
Browser compatibility
BCD tables only load in the browser
See also
- The
font-variant-alternates
property that uses values that this at-rule defines.