font-synthesis-small-caps

Baseline 已廣泛支援

此功能已成熟,並可在許多裝置和瀏覽器版本上執行。自 2023 年 3 月以來,它已在各種瀏覽器中可用。

font-synthesis-small-caps CSS 屬性讓你指定當字型家族中缺少小型大寫字母(small-caps)字形時,瀏覽器是否可以合成該字形。小型大寫字母通常採用大寫字母的形式,但會縮小到小寫字母的大小。

通常,使用簡寫屬性 font-synthesis 來控制所有字型合成值會更方便。

語法

css
/* Keyword values */
font-synthesis-small-caps: auto;
font-synthesis-small-caps: none;

/* Global values */
font-synthesis-small-caps: inherit;
font-synthesis-small-caps: initial;
font-synthesis-small-caps: revert;
font-synthesis-small-caps: revert-layer;
font-synthesis-small-caps: unset;

auto

表示如果需要,瀏覽器可以合成缺失的小型大寫字母字形。

none

表示不允許瀏覽器合成缺失的小型大寫字母字形。

正式定義

初始值auto
應用於所有元素和文字。它也適用於 ::first-letter::first-line
繼承性
計算值同指定值
動畫型別離散

正式語法

font-synthesis-small-caps = 
auto |
none

示例

停用小型大寫字母字形的合成

此示例展示了在 Montserrat 字型中關閉瀏覽器合成小型大寫字母字形。

HTML

html
<p class="english">
  These are the default <span class="small-caps">small-caps</span>,
  <strong>bold</strong>, and <em>oblique</em> typefaces.
</p>

<p class="english no-syn">
  The <span class="small-caps">small-caps</span> typeface is turned off here but
  not the <strong>bold</strong> and <em>oblique</em> typefaces.
</p>

CSS

css
@import "https://fonts.googleapis.com/css2?family=Montserrat&display=swap";

.english {
  font-family: "Montserrat", sans-serif;
}
.small-caps {
  font-variant: small-caps;
}
.no-syn {
  font-synthesis-small-caps: none;
}

結果

規範

規範
CSS 字型模組第 4 級
# font-synthesis-small-caps

瀏覽器相容性

另見