font-variation-settings
font-variation-settings CSS 描述符允許作者在 @font-face at-rule 中指定低階的 OpenType 或 TrueType 字型變體。此描述符的值與 font-variation-settings 屬性相同,但全域性關鍵字值除外。
由於此描述符在 @font-face at-rule 中設定字型物件的變體值,而不是設定整個元素的變體值,因此元素中只有部分字形可能使用此描述符渲染。
語法
css
/* Use the default settings */
font-variation-settings: normal;
/* Set values for OpenType axis names */
font-variation-settings: "xhgt" 0.7;
值
normal-
文字使用預設設定進行佈局。
<string> <number>-
渲染文字時,OpenType 軸名稱列表將傳遞給文字佈局引擎以啟用或停用字型功能。每個設定始終是 4 個 ASCII 字元的
<string>,後跟一個指示軸值的<number>。如果<string>字元數過多或過少,或者包含 U+20 - U+7E 碼點範圍之外的字元,則整個屬性無效。<number>可以是小數或負數。
正式定義
| 相關的 at-rule | @font-face |
|---|---|
| 初始值 | normal |
| 計算值 | 同指定值 |
正式語法
font-variation-settings =
normal |
[ <string> <number> ]#
示例
在 @font-face 規則中設定字型粗細和拉伸
css
@font-face {
font-family: "OpenTypeFont";
src: url("open_type_font.woff2") format("woff2");
font-weight: normal;
font-style: normal;
font-variation-settings:
"wght" 400,
"wdth" 300;
}
規範
| 規範 |
|---|
| CSS 字型模組第 4 級 # font-rend-desc |
瀏覽器相容性
載入中…