@font-feature-values - CSS: Cascading Style Sheets 编辑
The @font-feature-values
CSS at-rule lets you use a common name in the font-variant-alternates
property for features activated differently in OpenType. This can help simplify your CSS when using multiple fonts.
The @font-feature-values
at-rule may be used either at the top level of your CSS or 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, butident2: 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, butident2: 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, butident2: 2 4
isn't. @stylistic
- Specifies a feature name that will work with the
stylistic()
functional notation offont-variant-alternates
. A stylistic feature value definition allows only one value:ident1: 2
is valid, butident2: 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 an unlimited number of values:ident1: 2 4 12 1
maps to the OpenType valuesss02
,ss04
,ss12
, andss01
. Note that values higher than99
are valid, but don'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 either one or two values:ident1: 3
maps tocv03=1
, andident2: 2 4
maps tocv02=4
, butident2: 2 4 5
is invalid.
Formal syntax
@font-feature-values <family-name># { <feature-value-block-list> }where
<family-name> = <string> | <custom-ident>+
<feature-value-block-list> = <feature-value-block>+where
<feature-value-block> = <feature-type> '{' <feature-value-declaration-list> '}'
where
<feature-type> = @stylistic | @historical-forms | @styleset | @character-variant | @swash | @ornaments | @annotation
<feature-value-declaration-list> = <feature-value-declaration>where
<feature-value-declaration> = <custom-ident>: <integer>+;
Examples
Using @styleset in a @font-feature-values rule
/* 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);
}
Specifications
Specification | Status | Comment |
---|---|---|
CSS Fonts Module Level 4 The definition of '@font-feature-values' in that specification. | Working Draft | Initial definition. |
Browser compatibility
BCD tables only load in the browser
See also
- The
font-variant-alternates
property that uses values that this at-rule defines.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论