aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/font-kerning/index.html
blob: 3ef355842a15a8260e4219e12539ed85d875bcbf (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
---
title: font-kerning
slug: Web/CSS/font-kerning
translation_of: Web/CSS/font-kerning
---
<div>{{CSSRef}}</div>

<p><strong><code>font-kerning</code></strong> CSS 属性设置是否使用字体中储存的字距信息。</p>

<pre class="brush:css no-line-numbers">/* Keyword values */
font-kerning: auto;
font-kerning: normal;
font-kerning: none;

/* Global values */
font-kerning: inherit;
font-kerning: initial;
font-kerning: unset;
</pre>

<p><em>Kerning</em>(字距)定义了字母的分布情况。对于良好地规定了字距的字体,字距特性使得字母分布更为统一,阅读体验更佳。如下图所示,左侧的示例没有应用字距,而右侧使用了:</p>

<p><img alt="Example of font-kerning" src="https://mdn.mozillademos.org/files/8455/font-kerning.png" style="display: block; height: 84px; margin: auto; width: 180px;"></p>

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

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

<p><code>font-kerning</code> 属性通过以下的关键字进行指定。</p>

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

<dl>
 <dt><code>auto</code></dt>
 <dd>浏览器来决定是否使用字体字距。比如,一些浏览器会在小字体的情况下禁用字距,因为这会使得文本可读性下降。</dd>
 <dt><code>normal</code></dt>
 <dd>必须应用字体中的字距信息。</dd>
 <dt><code>none</code></dt>
 <dd>禁用字体中的字距信息。</dd>
</dl>

<h3 id="Formal_syntax">Formal syntax</h3>

<pre class="syntaxbox">{{csssyntax}}</pre>

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

<h3 id="HTML">HTML</h3>

<pre class="brush: html">&lt;div id="kern"&gt;&lt;/div&gt;
&lt;div id="nokern"&gt;&lt;/div&gt;
&lt;textarea id="input"&gt;AV T. ij&lt;/textarea&gt;</pre>

<h3 id="CSS">CSS</h3>

<pre class="brush: css">div {
  font-size: 2rem;
  font-family: serif;
}

#nokern {
  font-kerning: none;
}

#kern {
  font-kerning: normal;
}</pre>

<h3 id="JavaScript">JavaScript</h3>

<pre class="brush: js">var input  = document.getElementById('input'),
    kern   = document.getElementById('kern'),
    nokern = document.getElementById('nokern');

input.addEventListener('keyup', function() {
  kern.textContent = input.value; /* Update content */
  nokern.textContent = input.value;
});

kern.textContent = input.value; /* Initialize content */
nokern.textContent = input.value;
</pre>

<p>{{ EmbedLiveSample('Example') }}</p>

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

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">规格</th>
   <th scope="col">状态</th>
   <th scope="col">注释</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS3 Fonts', '#propdef-font-kerning', 'font-kerning')}}</td>
   <td>{{Spec2('CSS3 Fonts')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

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

<div class="hidden">该页面上的兼容性表是由结构化数据生成的。 如果你想对数据有所贡献, 请拉取<a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 并向我们提交你的代码</div>

<p>{{Compat("css.properties.font-kerning")}}</p>

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

<ul>
 <li>{{cssxref("font-variant")}}, {{cssxref("font-variant-position")}}, {{cssxref("font-variant-east-asian")}}, {{cssxref("font-variant-caps")}}, {{cssxref("font-variant-ligatures")}}, {{cssxref("font-variant-numeric")}}, {{cssxref("font-variant-alternates")}}, {{cssxref("font-synthesis")}}, {{cssxref("letter-spacing")}}</li>
</ul>