aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/font-feature-settings/index.html
blob: f4ca74abdce4bd2a4cc3d1e3919dbd4761278bdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
title: font-feature-settings
slug: Web/CSS/font-feature-settings
tags:
  - CSS
  - CSS 字体
  - CSS 属性
  - 参考
translation_of: Web/CSS/font-feature-settings
---
<div>{{CSSRef}}</div>

<p><strong><code>font-feature-settings</code></strong> 属性用于控制OpenType字体中的高级印刷功能。</p>

<div>{{EmbedInteractiveExample("pages/css/font-feature-settings.html")}}</div>



<h2 id="语法">语法</h2>

<pre class="brush:css no-line-numbers">/* 默认设置 */
font-feature-settings: normal;

/* 设置 OpenType 功能标签的值 */
font-feature-settings: "smcp";
font-feature-settings: "smcp" on;
font-feature-settings: "swsh" 2;
font-feature-settings: "smcp", "swsh" 2;

/* 全局值 */
font-feature-settings: inherit;
font-feature-settings: initial;
font-feature-settings: unset;
</pre>

<div class="note"><strong>Note:</strong> Web开发者应该尽可能的使用类似 {{cssxref("font-variant")}} 这样的短标记属性或者相关的速记标识属性等, 类似 {{cssxref("font-variant-ligatures")}}, {{cssxref("font-variant-caps")}}, {{cssxref("font-variant-east-asian")}}, {{cssxref("font-variant-alternates")}}, {{cssxref("font-variant-numeric")}} or {{cssxref("font-variant-position")}}.<br>
<br>
该属性是一个比较偏底层的功能接口,用于解决由于没有其他方法去访问和设置OpenType字体某些特性而无法解决一些特殊功能需求.<br>
<br>
特别需要注意的是,该CSS属性不应该用来开启大写字母转换.</div>

<p>{{cssinfo}}</p>

<h3 id="值"></h3>

<dl>
 <dt><code>normal</code></dt>
 <dd>文本使用默认设置进行布局。</dd>
 <dt><code>&lt;feature-tag-value&gt;</code></dt>
 <dd>在呈现文本时,OpenType要素标记值的列表被传递到文本布局引擎以启用或禁用字体特征。标签始终是4个ASCII字符的 {{cssxref("&lt;string&gt;")}} 。如果是U + 20 - U + 7E代码点范围以外的字符或字符个数不对,则整个属性无效。 <br>
 值是一个正整数。两个关键字on和off分别是1和0的同义词。如果未设置任何值,则默认值为1。对于非布尔型OpenType功能(例如,文体替代 <a href="http://www.microsoft.com/typography/otspec/features_pt.htm#salt">stylistic alternates</a>),该值意味着要选择特定的字形;对于布尔值,它是一个开关。</dd>
</dl>

<h3 id="形式语法">形式语法</h3>

{{csssyntax}}

<h2 id="实例">实例</h2>

<pre class="brush:css">/* 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";
}
</pre>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS3 Fonts', '#propdef-font-feature-settings', 'font-feature-settings')}}</td>
   <td>{{Spec2('CSS3 Fonts')}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<div>


<p>{{Compat("css.properties.font-feature-settings")}}</p>
</div>

<h2 id="其他参考">其他参考</h2>

<ul>
 <li><a href="https://www.fontfont.com/staticcontent/downloads/FF_OT_User_Guide.pdf">FontFont OpenType User Guide (pdf)</a></li>
 <li><a href="http://www.microsoft.com/typography/otspec/featurelist.htm">OpenType Feature Tags</a> 列表</li>
 <li><a href="http://blogs.msdn.com/b/ie/archive/2012/01/09/css-corner-using-the-whole-font.aspx">Using the whole font</a> ( -moz语法是旧的。在Gecko上,使用-ms语法,但使用-moz ).</li>
</ul>