aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/font-variation-settings
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/css/font-variation-settings
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/css/font-variation-settings')
-rw-r--r--files/zh-cn/web/css/font-variation-settings/index.html154
1 files changed, 154 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/font-variation-settings/index.html b/files/zh-cn/web/css/font-variation-settings/index.html
new file mode 100644
index 0000000000..e55f4740ce
--- /dev/null
+++ b/files/zh-cn/web/css/font-variation-settings/index.html
@@ -0,0 +1,154 @@
+---
+title: font-variation-settings
+slug: Web/CSS/font-variation-settings
+tags:
+ - font-variation-settings
+ - 可变字体
+translation_of: Web/CSS/font-variation-settings
+---
+<div>{{CSSRef}}</div>
+
+<p><strong><code>font-variation-settings</code></strong> CSS属性提供了对 <a href="/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide">variable font</a> 特征的低级控制,通过指定要更改的特征的四个字母轴名称及其值。</p>
+
+<div>{{EmbedInteractiveExample("pages/css/font-variation-settings.html")}}</div>
+
+
+
+<div class="note"><strong>Note</strong>: This property is a low-level mechanism designed to set variable font features where no other way to enable or access those features exist. You should only use it when no basic properties exist to set those features (e.g. {{cssxref("font-weight")}}, {{cssxref("font-style")}}).</div>
+
+<div class="note"><strong>Note</strong>: font characteristics set using <code>font-variation-settings</code> will always override those set using the corresponding basic font properties, e.g. <code>font-weight</code>, no matter where they appear in the cascade. <span class="zhc-markdown-block zhc-markdown-block--html">In some browsers, this is currently only true when the <code>@font-face</code> declaration includes a <code>font-weight</code> range.</span></div>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="brush:css no-line-numbers">/* Use the default settings */
+font-variation-settings: normal;
+
+/* Set values for variable font axis names */
+font-variation-settings: "XHGT" 0.7;
+
+/* Global values */
+font-variation-settings: inherit;
+font-variation-settings: initial;
+font-variation-settings: unset;
+</pre>
+
+<h3 id="Values">Values</h3>
+
+<p>This property's value can take one of two forms:</p>
+
+<dl>
+ <dt><code>normal</code></dt>
+ <dd>Text is laid out using default settings.</dd>
+ <dt><code>&lt;string&gt; &lt;number&gt;</code></dt>
+ <dd>When rendering text, the list of variable font axis names is passed to the text layout engine to enable or disable font features. Each setting is always one or more pairs consisting of a {{cssxref("&lt;string&gt;")}} of 4 ASCII characters followed by a {{cssxref("number")}} indicating the axis value to set. If the <code>&lt;string&gt;</code> has more or fewer characters or contains characters outside the U+20 - U+7E codepoint range, the whole property is invalid. The <code>&lt;number&gt;</code> can be fractional or negative, depending on the value range available in your font, as defined by the font designer.</dd>
+</dl>
+
+<h3 id="Formal_syntax">Formal syntax</h3>
+
+<pre class="syntaxbox">{{csssyntax}}</pre>
+
+<h2 id="Registered_and_custom_axes">Registered and custom axes</h2>
+
+<p>Variable font axes come in two types: <strong>registered</strong> and <strong>custom</strong>.</p>
+
+<p>Registered axes are the most commonly encountered — common enough that the authors of the specification felt they were worth standardizing. Note that this doesn't mean that the author has to include all of these in their font.</p>
+
+<p>Here are the registered axes along with their corresponding CSS properties:</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Axis Tag</th>
+ <th scope="col">CSS Property</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>"wght"</td>
+ <td>{{cssxref("font-weight")}}</td>
+ </tr>
+ <tr>
+ <td>"wdth"</td>
+ <td>{{cssxref("font-stretch")}}</td>
+ </tr>
+ <tr>
+ <td>"slnt" (slant)</td>
+ <td>{{cssxref("font-style")}}: <code>oblique + angle</code></td>
+ </tr>
+ <tr>
+ <td>"ital"</td>
+ <td>{{cssxref("font-style")}}: <code>italic</code></td>
+ </tr>
+ <tr>
+ <td>"opsz"</td>
+ <td>
+ <p>{{cssxref("font-optical-sizing")}}</p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>Custom axes can be anything the font designer wants to vary in their font, for example ascender or descender heights, the size of serifs, or anything else they can imagine. Any axis can be used as long as it is given a unique 4-character axis. Some will end up becoming more common, and may even become registered over time.</p>
+
+<div class="note">
+<p><strong>Note</strong>: Registered axis tags are identified using lower-case tags, whereas custom axes should be given upper-case tags. Note that font designers aren't forced follow this practice in any way, and some won't. The important takeaway here is that axis tags are case-sensitive.</p>
+</div>
+
+<h2 id="Examples">Examples</h2>
+
+<p>See below for interactive examples demonstrating the registered axes. You can find a number of other variable fonts examples at our <a href="/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide">Variable fonts guide</a>, <a class="external external-icon" href="https://v-fonts.com/" rel="noopener">v-fonts.com</a>, and <a class="external external-icon" href="https://www.axis-praxis.org/" rel="noopener">axis-praxis.org</a>.</p>
+
+<div class="warning">
+<p><strong>Warning</strong>: In order to use variable fonts on your operating system, you need to make sure that it is up to date. For example Linux OSes need the latest Linux Freetype version, and macOS prior to 10.13 does not support variable fonts. If your operating system is not up to date, you will not be able to use variable fonts in web pages or the Firefox Developer Tools.</p>
+</div>
+
+<h3 id="Weight_wght">Weight (wght)</h3>
+
+<p>The following live example's CSS can be edited to allow you to play with font weight values.</p>
+
+<div>{{EmbedGHLiveSample("css-examples/variable-fonts/weight.html", '100%', 520)}}</div>
+
+<h3 id="Slant_slnt">Slant (slnt)</h3>
+
+<p>The following live example's CSS can be edited to allow you to play with font slant/oblique values.</p>
+
+<div>{{EmbedGHLiveSample("css-examples/variable-fonts/slant.html", '100%', 520)}}</div>
+
+<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('CSS4 Fonts', '#low-level-font-variation-settings-control-the-font-variation-settings-property', 'font-variation-settings')}}</td>
+ <td>{{Spec2('CSS4 Fonts')}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>{{cssinfo}}</p>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+
+
+<p>{{Compat("css.properties.font-variation-settings")}}</p>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide">Variable fonts guide</a></li>
+ <li><a href="https://www.microsoft.com/typography/otspec180/otvaroverview.htm">OpenType Font Variations Overview</a></li>
+ <li><a href="https://www.microsoft.com/typography/otspec/dvaraxisreg.htm">OpenType Design-Variation Axis Tag Registry</a></li>
+</ul>
+
+<div id="gtx-trans" style="position: absolute; left: 589px; top: 119px;">
+<div class="gtx-trans-icon"></div>
+</div>