字体功能的设置 | font-feature-settings
font-feature-settings
font-feature-settings
CSS属性可让您控制OpenType字体中的高级印刷功能。
/* Use the default settings */
font-feature-settings: normal;
/* Set values for OpenType feature tags */
font-feature-settings: "smcp";
font-feature-settings: "smcp" on;
font-feature-settings: "swsh" 2;
font-feature-settings: "smcp", "swsh" 2;
/* Global values */
font-feature-settings: inherit;
font-feature-settings: initial;
font-feature-settings: unset;
语法
注:
只要有可能,Web作者应该使用font-variant
速记属性或相关的速记属性font-variant-ligatures
,font-variant-caps
,font-variant-east-asian
,font-variant-alternates
,font-variant-numeric
或font-variant-position
。
此属性是一个低级特性,用于处理没有其他方式启用或访问OpenType字体功能的特殊情况。
特别是,这个CSS属性不应该被用来启用小型大写字母。
初始值 | normal |
---|---|
应用于 | all elements. It also applies to ::first-letter and ::first-line. |
继承自 | yes |
媒体 | visual |
计算值 | as specified |
动画类型 | discrete |
规范顺序 | the unique non-ambiguous order defined by the formal grammar |
取值
normal
使用默认设置布局文本。
该值是一个正整数。这两个关键字on
,off
分别代表1
和0
。如果没有设置值,则默认值为1
。对于非布尔型OpenType特征(例如文体替代),该值意味着要选择特定的字形; 对于布尔值,它是一个开关。
形式语法
normal | <feature-tag-value>#where
<feature-tag-value> = <string> [ <integer> | on | off ]?
实例
/* use small-cap alternate glyphs */
.smallcaps { font-feature-settings: "smcp" on; }
/* convert both upper and lowercase to small caps (affects punctuation also) */
.allsmallcaps { font-feature-settings: "c2sc", "smcp"; }
/* enable historical forms */
.hist { font-feature-settings: "hist"; }
/* disable common ligatures, usually on by default */
.noligs { font-feature-settings: "liga" 0; }
/* enable tabular (monospaced) figures */
td.tabular { font-feature-settings: "tnum"; }
/* enable automatic fractions */
.fractions { font-feature-settings: "frac"; }
/* use the second available swash character */
.swash { font-feature-settings: "swsh" 2; }
/* enable stylistic set 7 */
.fancystyle {
font-family: Gabriola; /* available on Windows 7, and on Mac OS */
font-feature-settings: "ss07";
}
规范
Specification | Status | Comment |
---|---|---|
CSS Fonts Module Level 3The definition of 'font-feature-settings' in that specification. | Candidate Recommendation | Initial definition |
浏览器兼容性
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 16.0 -webkit 48.0 (unprefixed) | 40.15063.0.0 | 4.0 (2.0) -moz 1 29.0 (29.0) -moz 2 34.0 (34.0) 3 | 10.0 | 15.0 -webkit | 9.1 (partial support in versions 4.0-6.0) |
Feature | Android | Android Webview | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|---|
Basic support | 4.4 | 48.0 (unprefixed) | 48.0 (unprefixed) | (Yes) | 4.0 (2.0) -moz 1 29.0 (29.0) -moz 2 34.0 (34.0) 3 | ? | 24 | 9.3 (partial support in versions 3.2-6.1) |