首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

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

font-feature-settingsCSS属性可让您控制OpenType字体中的高级印刷功能。

代码语言:javascript
复制
/* 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使用默认设置布局文本。

<feature-tag-value>在呈现文本时,OpenType功能标记值列表将传递给文本布局引擎,以启用或禁用字体功能。标记始终是<string>四个ASCII字符。如果它有或多或少的字符或包含U+20-U+7e码点范围之外的字符,则整个属性无效。

该值是一个正整数。这两个关键字onoff分别代表10。如果没有设置值,则默认值为1。对于非布尔型OpenType特征(例如文体替代),该值意味着要选择特定的字形; 对于布尔值,它是一个开关。

形式语法

代码语言:javascript
复制
normal | <feature-tag-value>#where 
<feature-tag-value> = <string> [ <integer> | on | off ]?

实例

代码语言:javascript
复制
/* 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)

扫码关注腾讯云开发者

领取腾讯云代金券