aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/@font-face/font-style/index.html
blob: a8c5e39654c2043dbe00d10ca78c81b0b74121b4 (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
122
123
124
125
126
127
128
129
130
131
132
133
---
title: font-style
slug: Web/CSS/@font-face/font-style
translation_of: Web/CSS/@font-face/font-style
---
<p>{{CSSRef}}</p>

<h2 id="概述">概述</h2>

<p><strong>font-style</strong> 描述符允许开发者在@font-rule规则中为指定字体样式(该条目区别于font-style,意指用在@font-rule中的font-style属性)</p>

<p>For a particular font family, authors can download various font faces which correspond to the different styles of the same font family, and then use the <code>font-style </code>descriptor to explicitly specify the font face's style. The values for the CSS descriptor is same as that of its corresponding font property.</p>

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

<h2 id="Syntax">Syntax</h2>

<div class="syntaxbox">
<pre class="brush: css">font-style: normal;
font-style: italic;
font-style: oblique;</pre>

<h3 id="Values">Values</h3>

<p><code><strong>normal</strong></code><br>
 Selects the normal version of the font-family.</p>

<p><strong><code>italic</code></strong><br>
 Specifies that font-face is an italicized version of the normal font .</p>

<p><strong><code>oblique</code></strong><br>
 Specifies that the font-face is an artificially sloped version of the normal font.</p>

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

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

<h2 id="Examples">Examples</h2>

<p>As an example, consider the garamond font family, in its normal form, we get the following result:</p>

<pre class="brush: css">@font-face {
  font-family: garamond;
  src: url('garamond.ttf');
}</pre>

<p><img alt="unstyled Garamond" src="https://mdn.mozillademos.org/files/12265/garamondunstyled.JPG" style="height: 101px; width: 276px;"></p>

<p>The italicized version of this text uses the same glyphs present in the unstyled version, but they are artificially sloped by a few degrees.</p>

<p><img alt="artificially sloped garamond" src="https://mdn.mozillademos.org/files/12267/garamondartificialstyle.JPG" style="height: 101px; width: 276px;"></p>

<p>On the other hand, if a true italicized version of the font family exists, we can include it in the <code>src </code>descriptor and specify the font style as italic, so that it is clear that the font is italicized. True italics use different glyphs and are a bit different from their upright counterparts, having some unique features and generally have a rounded and calligraphic quality. These fonts are specially created by font designers and are <strong>not</strong> artificially sloped.</p>

<pre class="brush: css">@font-face {
  font-family: garamond;
  src: url('garamond-italic.ttf');
  font-style: italic;
}</pre>

<p><img alt="italic garamond" src="https://mdn.mozillademos.org/files/12269/garamonditalic.JPG" style="height: 101px; width: 267px;"></p>

<h2 id="Specifications">Specifications</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', '#descdef-font-face-unicode-range', 'unicode-range')}}</td>
   <td>{{Spec2('CSS3 Fonts')}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table" style="height: 91px; width: 591px;">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Firefox (Gecko)</th>
   <th>Chrome</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatGeckoDesktop("1.9.1")}}</td>
   <td>4.0  </td>
   <td>4.0</td>
   <td>10.0</td>
   <td>3.1</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mini</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoMobile("1.9.1")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}}</td>
   <td>10.0</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>
</div>