CSS

字体功能的设置 | font-feature-settings

font-feature-settings

font-feature-settingsCSS属性可让您控制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-ligaturesfont-variant-capsfont-variant-east-asianfont-variant-alternatesfont-variant-numericfont-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使用默认设置布局文本。

该值是一个正整数。这两个关键字onoff分别代表10。如果没有设置值,则默认值为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"; }

规范

SpecificationStatusComment
CSS Fonts Module Level 3The definition of 'font-feature-settings' in that specification.Candidate RecommendationInitial definition

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support16.0 -webkit 48.0 (unprefixed)40.15063.0.04.0 (2.0) -moz 1 29.0 (29.0) -moz 2 34.0 (34.0) 310.015.0 -webkit9.1 (partial support in versions 4.0-6.0)

FeatureAndroidAndroid WebviewChrome for AndroidEdgeFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support4.448.0 (unprefixed)48.0 (unprefixed)(Yes)4.0 (2.0) -moz 1 29.0 (29.0) -moz 2 34.0 (34.0) 3?249.3 (partial support in versions 3.2-6.1)