字體配置/示例 - Arch Linux 中文维基

跳至內容

# 字體配置/示例

出自 Arch Linux 中文维基
< 字体配置
翻譯狀態：

- 本文（或部分內容）譯自 Font configuration/Examples，最近一次同步於 2023-01-17，若英文版本有所更改，則您可以幫助同步與翻譯更改的內容。
- 您可以在 ArchWiki 的對應頁面找到本文翻譯的原始修訂歷史。
- 本文可能與英文原文存在出入。

閱讀主文章：字體配置。

配置可能一定程度上有所不同。請發布 Fontconfig 配置並解釋原因。

中文用戶可能更希望查看字體配置/中文。

## 微調字體

    ~/.config/fontconfig/fonts.conf

    <?xml version='1.0'?>
    <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
    <fontconfig>
      <match target="font">
        <edit mode="assign" name="antialias">
          <bool>true</bool>
        </edit>
        <edit mode="assign" name="embeddedbitmap">
          <bool>false</bool>
        </edit>
        <edit mode="assign" name="hinting">
          <bool>true</bool>
        </edit>
        <edit mode="assign" name="hintstyle">
          <const>hintslight</const>
        </edit>
        <edit mode="assign" name="lcdfilter">
          <const>lcddefault</const>
        </edit>
        <edit mode="assign" name="rgba">
          <const>rgb</const>
        </edit>
      </match>
    </fontconfig>

## 對斜體和粗體禁用微調

    <?xml version='1.0'?>
    <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
    <fontconfig>
      <match target="font" >
        <edit mode="assign" name="autohint">  <bool>true</bool></edit>
        <edit mode="assign" name="hinting">	  <bool>false</bool></edit>
        <edit mode="assign" name="lcdfilter"> <const>lcddefault</const></edit>
        <edit mode="assign" name="hintstyle"> <const>hintslight</const></edit>
        <edit mode="assign" name="antialias"> <bool>true</bool></edit>
        <edit mode="assign" name="rgba">      <const>rgb</const></edit>
      </match>

      <match target="font">
        <test name="pixelsize" qual="any" compare="more"><double>15</double></test>
        <edit mode="assign" name="lcdfilter"><const>lcdlight</const></edit>
        <edit mode="assign" name="hintstyle"><const>hintnone</const></edit>
      </match>

      <match target="font">
        <test name="weight" compare="more"><const>medium</const></test>
        <edit mode="assign" name="hintstyle"><const>hintnone</const></edit>
        <edit mode="assign" name="lcdfilter"><const>lcdlight</const></edit>
      </match>

      <match target="font">
        <test name="slant"  compare="not_eq"><double>0</double></test>
        <edit mode="assign" name="hintstyle"><const>hintnone</const></edit>
        <edit mode="assign" name="lcdfilter"><const>lcdlight</const></edit>
      </match>

    </fontconfig>

## 僅對較大的字體啟用抗鋸齒

一些用戶更喜歡抗鋸齒所不能提供的，更清晰的渲染：

    <?xml version="1.0"?>
    <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
    <fontconfig>
      <match target="font">
        <edit name="antialias" mode="assign">
          <bool>false</bool>
        </edit>
      </match>

      <match target="font" >
        <test name="size" qual="any" compare="more">
          <double>12</double>
        </test>
        <edit name="antialias" mode="assign">
          <bool>true</bool>
        </edit>
      </match>

      <match target="font" >
        <test name="pixelsize" qual="any" compare="more">
          <double>16</double>
        </test>
        <edit name="antialias" mode="assign">
          <bool>true</bool>
        </edit>
      </match>
    </fontconfig>

## 禁用粗體

當某個字體不能很好地以粗體字形顯示，並且不能在應用程式中禁用粗體字時（例如 st）有用。

    ...
    <match target="pattern">
        <test qual="any" name="family">
            <string>Envy Code R</string>
        </test>
        <test name="weight" compare="more">
            <const>medium</const>
        </test>
        <edit name="weight" mode="assign" binding="same">
            <const>medium</const>
        </edit>
    </match>
    ...

## 禁用等寬字體的連字

這可以防止像 "ffi" 這樣的字母組合在某些等寬字體中被壓縮成單個寬度的字符。需要複製整個 `<match>` 塊以包含額外的字體。

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
    <fontconfig>
      <description>Disable ligatures for monospaced fonts to avoid ff, fi, ffi, etc. becoming only one character wide</description>

      <match target="font">
        <test name="family" compare="eq" ignore-blanks="true">
          <string>Nimbus Mono PS</string>
        </test>
        <edit name="fontfeatures" mode="append">
          <string>liga off</string>
          <string>dlig off</string>
        </edit>
      </match>
    </fontconfig>

一些其他字體也可能需要禁用如 `calt` 和/或 `clig` 等排版特徵。

您可以使用以下命令測試其有效性：

    $ echo -e "| worksheet |\n| buffering |\n| difficult |\n| finishing |\n| different |\n| efficient |" | pango-view --font="Nimbus Mono PS" /dev/stdin

有些程序（比如 Firefox）不支持 `fontfeatures` 標籤，所以這對於那些用另一種字體替換的程序來說是唯一的選擇。有關詳細信息，參見字體配置#設置默認和後備字體。

## 默認字體

為了保證字體的一致性，所有應用程式都應該設置為使用襯線（serif）、無襯線（sans-serif）和等寬（monospace）別名，這些別名通過 Fontconfig 映射到特定的字體。有關選項和示例，請參見 Metric-compatible fonts。

### 阿拉伯語

以下示例 fonts.conf 為阿拉伯語指定了單獨的默認字體，並為拉丁字母保留西式字體。您需要 ttf-arabeyes-fontsAUR 或 noto-fonts包 才能使以下各項工作。您還可以選擇安裝任何其他阿拉伯語字體，並根據您的喜好相應地更改下面的字體名稱。

    <?xml version='1.0'?>
    <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
    <fontconfig>

    <!-- Default font for the Arabic language (no fc-match pattern) -->
     <match>
      <test compare="contains" name="lang">
       <string>ar</string>
      </test>
      <edit mode="prepend" name="family">
       <string>Tholoth</string>
      </edit>
     </match>
    </fontconfig>

上述方法應該對大多數應用程式有用，但有些應用程式，如 Chromium 在語言匹配測試中不起作用。如果你發現一些應用程式不使用你選擇的字體，你可以使用下面這些似乎有效的的 alias 和 prefer 標籤。

    <?xml version='1.0'?>
    <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
    <fontconfig>

    <!-- Fallback fonts preference order -->
     <alias>
      <family>sans-serif</family>
      <prefer>
       <family>Noto Sans</family>
       <family>Open Sans</family>
       <family>Droid Sans</family>
       <family>Roboto</family>
       <family>Tholoth</family>
       <family>Noto Sans Arabic</family>
      </prefer>
     </alias>
     <alias>
      <family>serif</family>
      <prefer>
       <family>Noto Serif</family>
       <family>Droid Serif</family>
       <family>Roboto Slab</family>
       <family>Tholoth</family>
       <family>Noto Sans Arabic</family>
      </prefer>
     </alias>
     <alias>
      <family>monospace</family>
      <prefer>
       <family>Noto Sans Mono</family>
       <family>Inconsolata</family>
       <family>Droid Sans Mono</family>
       <family>Roboto Mono</family>
      </prefer>
     </alias>

    </fontconfig>

### 日語

以下示例 fonts.conf 同樣為日語區域設置（ja_JP）指定默認字體，並為拉丁字母保留西式字體。

    <?xml version='1.0'?>
    <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
    <fontconfig>

    <!-- Default font (no fc-match pattern) -->
     <match>
      <edit mode="prepend" name="family">
       <string>Noto Sans</string>
      </edit>
     </match>

    <!-- Default font for the ja_JP locale (no fc-match pattern) -->
     <match>
      <test compare="contains" name="lang">
       <string>ja</string>
      </test>
      <edit mode="prepend" name="family">
       <string>Noto Sans CJK JP</string>
      </edit>
     </match>

    <!-- Default sans-serif font -->
     <match target="pattern">
       <test qual="any" name="family"><string>sans-serif</string></test>
       <!--<test qual="any" name="lang"><string>ja</string></test>-->
       <edit name="family" mode="prepend" binding="same"><string>Noto Sans</string>  </edit>
     </match>

    <!-- Default serif fonts -->
     <match target="pattern">
       <test qual="any" name="family"><string>serif</string></test>
       <edit name="family" mode="prepend" binding="same"><string>Noto Serif</string>  </edit>
       <edit name="family" mode="append" binding="same"><string>IPAPMincho</string>  </edit>
       <edit name="family" mode="append" binding="same"><string>HanaMinA</string>  </edit>
     </match>

    <!-- Default monospace fonts -->
     <match target="pattern">
       <test qual="any" name="family"><string>monospace</string></test>
       <edit name="family" mode="prepend" binding="same"><string>Noto Sans Mono</string></edit>
       <edit name="family" mode="append" binding="same"><string>Inconsolatazi4</string></edit>
       <edit name="family" mode="append" binding="same"><string>IPAGothic</string></edit>
     </match>

    <!-- Fallback fonts preference order -->
     <alias>
      <family>sans-serif</family>
      <prefer>
       <family>Noto Sans</family>
       <family>Open Sans</family>
       <family>Droid Sans</family>
       <family>Ubuntu</family>
       <family>Roboto</family>
       <family>NotoSansCJK</family>
       <family>Source Han Sans JP</family>
       <family>IPAPGothic</family>
       <family>VL PGothic</family>
       <family>Koruri</family>
      </prefer>
     </alias>
     <alias>
      <family>serif</family>
      <prefer>
       <family>Noto Serif</family>
       <family>Droid Serif</family>
       <family>Roboto Slab</family>
       <family>IPAPMincho</family>
      </prefer>
     </alias>
     <alias>
      <family>monospace</family>
      <prefer>
       <family>Noto Sans Mono</family>
       <family>Inconsolatazi4</family>
       <family>Ubuntu Mono</family>
       <family>Droid Sans Mono</family>
       <family>Roboto Mono</family>
       <family>IPAGothic</family>
      </prefer>
     </alias>

    </fontconfig>

### 中文

    ~/.config/fontconfig/fonts.conf
    or
    /etc/fonts/local.conf

    <?xml version="1.0"?>
    <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
    <fontconfig>

        <match target="font">
            <edit name="embeddedbitmap" mode="assign">
                <bool>false</bool>
            </edit>
        </match>

        <match>
            <test qual="any" name="family">
                <string>serif</string>
            </test>
            <edit name="family" mode="prepend" binding="strong">
                <string>Noto Serif</string>
            </edit>
        </match>
        <match target="pattern">
            <test qual="any" name="family">
                <string>sans-serif</string>
            </test>
            <edit name="family" mode="prepend" binding="strong">
                <string>Roboto</string>
            </edit>
        </match>
        <match target="pattern">
            <test qual="any" name="family">
                <string>monospace</string>
            </test>
            <edit name="family" mode="prepend" binding="strong">
                <string>DejaVu Sans Mono</string>
            </edit>
        </match>

        <match>
            <test name="lang" compare="contains">
                <string>zh</string>
            </test>
            <test name="family">
                <string>serif</string>
            </test>
            <edit name="family" mode="prepend">
                <string>Source Han Serif CN</string>
            </edit>
        </match>
        <match>
            <test name="lang" compare="contains">
                <string>zh</string>
            </test>
            <test name="family">
                <string>sans-serif</string>
            </test>
            <edit name="family" mode="prepend">
                <string>Source Han Sans CN</string>
            </edit>
        </match>
        <match>
            <test name="lang" compare="contains">
                <string>zh</string>
            </test>
            <test name="family">
                <string>monospace</string>
            </test>
            <edit name="family" mode="prepend">
                <string>Noto Sans Mono CJK SC</string>
            </edit>
        </match>

    <!--Windows & Linux Chinese fonts. -->
        <match target="pattern">
            <test qual="any" name="family">
                <string>WenQuanYi Zen Hei</string>
            </test>
            <edit name="family" mode="assign" binding="same">
                <string>Source Han Sans CN</string>
            </edit>
        </match>
        <match target="pattern">
                    <test qual="any" name="family">
                            <string>WenQuanYi Micro Hei</string>
                    </test>
                    <edit name="family" mode="assign" binding="same">
                            <string>Source Han Sans CN</string>
                    </edit>
        </match>
            <match target="pattern">
                    <test qual="any" name="family">
                            <string>WenQuanYi Micro Hei Light</string>
                    </test>
                    <edit name="family" mode="assign" binding="same">
                            <string>Source Han Sans CN</string>
                    </edit>
            </match>
        <match target="pattern">
                    <test qual="any" name="family">
                            <string>Microsoft YaHei</string>
                    </test>
                    <edit name="family" mode="assign" binding="same">
                            <string>Source Han Sans CN</string>
                    </edit>
            </match>
            <match target="pattern">
                    <test qual="any" name="family">
                            <string>SimHei</string>
                    </test>
                    <edit name="family" mode="assign" binding="same">
                            <string>Source Han Sans CN</string>
                    </edit>
            </match>
            <match target="pattern">
                    <test qual="any" name="family">
                            <string>SimSun</string>
                    </test>
                    <edit name="family" mode="assign" binding="same">
                            <string>Source Han Serif CN</string>
                    </edit>
            </match>
            <match target="pattern">
                    <test qual="any" name="family">
                            <string>SimSun-18030</string>
                    </test>
                    <edit name="family" mode="assign" binding="same">
                            <string>Source Han Serif CN</string>
                    </edit>
            </match>
    </fontconfig>

#### Noto Fonts 中文字體

使用 Noto Fonts，同時用文泉驛微米黑替換 Microsoft 字體：

    ~/.config/fontconfig/fonts.conf
    or
    /etc/fonts/local.conf

    <?xml version="1.0"?>
    <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
    <fontconfig>
        <match target="font">
            <edit name="embeddedbitmap" mode="assign">
                <bool>false</bool>
            </edit>
        </match>
        <match>
            <test qual="any" name="family">
                <string>serif</string>
            </test>
            <edit name="family" mode="prepend" binding="strong">
                <string>Noto Serif</string>
            </edit>
        </match>
        <match target="pattern">
            <test qual="any" name="family">
                <string>sans-serif</string>
            </test>
            <edit name="family" mode="prepend" binding="strong">
                <string>Noto Sans</string>
            </edit>
        </match>
        <match target="pattern">
            <test qual="any" name="family">
                <string>monospace</string>
            </test>
            <edit name="family" mode="prepend" binding="strong">
                <string>Noto Sans Mono</string>
            </edit>
        </match>
        <match>
            <test name="lang" compare="contains">
                <string>zh</string>
            </test>
            <test name="family">
                <string>serif</string>
            </test>
            <edit name="family" mode="prepend">
                <string>Noto Serif CJK SC</string>
            </edit>
        </match>
        <match>
            <test name="lang" compare="contains">
                <string>zh</string>
            </test>
            <test name="family">
                <string>sans-serif</string>
            </test>
            <edit name="family" mode="prepend">
                <string>Noto Sans CJK SC</string>
            </edit>
        </match>
        <match>
            <test name="lang" compare="contains">
                <string>zh</string>
            </test>
            <test name="family">
                <string>monospace</string>
            </test>
            <edit name="family" mode="prepend">
                <string>Noto Sans Mono CJK SC</string>
            </edit>
        </match>

        <!--WenQuanYi Zen Hei -> WenQuanYi Micro Hei -->
        <match target="pattern">
            <test qual="any" name="family">
                <string>WenQuanYi Zen Hei</string>
            </test>
            <edit name="family" mode="assign" binding="same">
                <string>WenQuanYi Micro Hei</string>
            </edit>
        </match>
        <match target="pattern">
            <test qual="any" name="family">
                <string>WenQuanYi Zen Hei Lite</string>
            </test>
            <edit name="family" mode="assign" binding="same">
                <string>WenQuanYi Micro Hei Lite</string>
            </edit>
        </match>
        <match target="pattern">
            <test qual="any" name="family">
                <string>WenQuanYi Zen Hei Mono</string>
            </test>
            <edit name="family" mode="assign" binding="same">
                <string>WenQuanYi Micro Hei Mono</string>
            </edit>
        </match>

        <!--Microsoft YaHei, SimHei, SimSun -> WenQuanYi Micro Hei -->
        <match target="pattern">
            <test qual="any" name="family">
                <string>Microsoft YaHei</string>
            </test>
            <edit name="family" mode="assign" binding="same">
                <string>WenQuanYi Micro Hei</string>
            </edit>
        </match>
        <match target="pattern">
            <test qual="any" name="family">
                <string>SimHei</string>
            </test>
            <edit name="family" mode="assign" binding="same">
                <string>WenQuanYi Micro Hei</string>
            </edit>
        </match>
        <match target="pattern">
            <test qual="any" name="family">
                <string>SimSun</string>
            </test>
            <edit name="family" mode="assign" binding="same">
                <string>WenQuanYi Micro Hei</string>
            </edit>
        </match>
        <match target="pattern">
            <test qual="any" name="family">
                <string>SimSun-18030</string>
            </test>
            <edit name="family" mode="assign" binding="same">
                <string>WenQuanYi Micro Hei</string>
            </edit>
        </match>
    </fontconfig>

### 首選拉丁字體的同時使用 CJK 字體

需要 noto-fonts-cjk包。

你可以將 `PT Serif`/`Roboto`/`Cascadia Code PL` 替換為您喜歡的襯線/無襯線/等寬字體。

    ~/.config/fontconfig/fonts.conf

    <?xml version="1.0"?>
    <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
    <fontconfig>
      <!-- Default serif font -->
      <alias binding="strong">
        <family>serif</family>
        <prefer>
          <family>PT Serif</family>
        </prefer>
      </alias>

      <!-- Default sans-serif font -->
      <alias binding="strong">
        <family>sans-serif</family>
        <prefer>
          <family>Roboto</family>
        </prefer>
      </alias>

      <!-- Default monospace font -->
      <alias binding="strong">
        <family>monospace</family>
        <prefer>
          <family>Cascadia Code PL</family>
        </prefer>
      </alias>

      <!-- Default system-ui font -->
      <alias binding="strong">
        <family>system-ui</family>
        <prefer>
          <family>Roboto</family>
        </prefer>
      </alias>

      <!-- Serif CJK -->

      <!-- Default serif when the "lang" attribute is not given -->
      <!-- You can change this font to the language variant you want -->
      <match target="pattern">
        <test name="family">
          <string>serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Serif CJK SC</string>
        </edit>
      </match>

      <!-- Japanese -->
      <!-- "lang=ja" or "lang=ja-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>ja</string>
        </test>
        <test name="family">
          <string>serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Serif CJK JP</string>
        </edit>
      </match>

      <!-- Korean -->
      <!-- "lang=ko" or "lang=ko-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>ko</string>
        </test>
        <test name="family">
          <string>serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Serif CJK KR</string>
        </edit>
      </match>

      <!-- Chinese -->
      <!-- "lang=zh" or "lang=zh-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh</string>
        </test>
        <test name="family">
          <string>serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Serif CJK SC</string>
        </edit>
      </match>
      <!-- "lang=zh-hans" or "lang=zh-hans-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-hans</string>
        </test>
        <test name="family">
          <string>serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Serif CJK SC</string>
        </edit>
      </match>
      <!-- "lang=zh-hant" or "lang=zh-hant-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-hant</string>
        </test>
        <test name="family">
          <string>serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Serif CJK TC</string>
        </edit>
      </match>
      <!-- Compatible -->
      <!-- "lang=zh-cn" or "lang=zh-cn-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-cn</string>
        </test>
        <test name="family">
          <string>serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Serif CJK SC</string>
        </edit>
      </match>
      <!-- "lang=zh-tw" or "lang=zh-tw-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-tw</string>
        </test>
        <test name="family">
          <string>serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Serif CJK TC</string>
        </edit>
      </match>

      <!-- Sans CJK -->

      <!-- Default sans-serif when the "lang" attribute is not given -->
      <!-- You can change this font to the language variant you want -->
      <match target="pattern">
        <test name="family">
          <string>sans-serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK SC</string>
        </edit>
      </match>

      <!-- Japanese -->
      <!-- "lang=ja" or "lang=ja-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>ja</string>
        </test>
        <test name="family">
          <string>sans-serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK JP</string>
        </edit>
      </match>

      <!-- Korean -->
      <!-- "lang=ko" or "lang=ko-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>ko</string>
        </test>
        <test name="family">
          <string>sans-serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK KR</string>
        </edit>
      </match>

      <!-- Chinese -->
      <!-- "lang=zh" or "lang=zh-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh</string>
        </test>
        <test name="family">
          <string>sans-serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK SC</string>
        </edit>
      </match>
      <!-- "lang=zh-hans" or "lang=zh-hans-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-hans</string>
        </test>
        <test name="family">
          <string>sans-serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK SC</string>
        </edit>
      </match>
      <!-- "lang=zh-hant" or "lang=zh-hant-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-hant</string>
        </test>
        <test name="family">
          <string>sans-serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK TC</string>
        </edit>
      </match>
      <!-- "lang=zh-hant-hk" or "lang=zh-hant-hk-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-hant-hk</string>
        </test>
        <test name="family">
          <string>sans-serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK HK</string>
        </edit>
      </match>
      <!-- Compatible -->
      <!-- "lang=zh-cn" or "lang=zh-cn-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-cn</string>
        </test>
        <test name="family">
          <string>sans-serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK SC</string>
        </edit>
      </match>
      <!-- "lang=zh-tw" or "lang=zh-tw-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-tw</string>
        </test>
        <test name="family">
          <string>sans-serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK TC</string>
        </edit>
      </match>
      <!-- "lang=zh-hk" or "lang=zh-hk-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-hk</string>
        </test>
        <test name="family">
          <string>sans-serif</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK HK</string>
        </edit>
      </match>

      <!-- Mono CJK -->

      <!-- Default monospace when the "lang" attribute is not given -->
      <!-- You can change this font to the language variant you want -->
      <match target="pattern">
        <test name="family">
          <string>monospace</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans Mono CJK SC</string>
        </edit>
      </match>

      <!-- Japanese -->
      <!-- "lang=ja" or "lang=ja-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>ja</string>
        </test>
        <test name="family">
          <string>monospace</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans Mono CJK JP</string>
        </edit>
      </match>

      <!-- Korean -->
      <!-- "lang=ko" or "lang=ko-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>ko</string>
        </test>
        <test name="family">
          <string>monospace</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans Mono CJK KR</string>
        </edit>
      </match>

      <!-- Chinese -->
      <!-- "lang=zh" or "lang=zh-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh</string>
        </test>
        <test name="family">
          <string>monospace</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans Mono CJK SC</string>
        </edit>
      </match>
      <!-- "lang=zh-hans" or "lang=zh-hans-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-hans</string>
        </test>
        <test name="family">
          <string>monospace</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans Mono CJK SC</string>
        </edit>
      </match>
      <!-- "lang=zh-hant" or "lang=zh-hant-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-hant</string>
        </test>
        <test name="family">
          <string>monospace</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans Mono CJK TC</string>
        </edit>
      </match>
      <!-- "lang=zh-hant-hk" or "lang=zh-hant-hk-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-hant-hk</string>
        </test>
        <test name="family">
          <string>monospace</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans Mono CJK HK</string>
        </edit>
      </match>
      <!-- Compatible -->
      <!-- "lang=zh-cn" or "lang=zh-cn-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-cn</string>
        </test>
        <test name="family">
          <string>monospace</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans Mono CJK SC</string>
        </edit>
      </match>
      <!-- "lang=zh-tw" or "lang=zh-tw-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-tw</string>
        </test>
        <test name="family">
          <string>monospace</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans Mono CJK TC</string>
        </edit>
      </match>
      <!-- "lang=zh-hk" or "lang=zh-hk-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-hk</string>
        </test>
        <test name="family">
          <string>monospace</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans Mono CJK HK</string>
        </edit>
      </match>

      <!-- System UI CJK -->

      <!-- Default system-ui when the "lang" attribute is not given -->
      <!-- You can change this font to the language variant you want -->
      <match target="pattern">
        <test name="family">
          <string>system-ui</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK SC</string>
        </edit>
      </match>

      <!-- Japanese -->
      <!-- "lang=ja" or "lang=ja-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>ja</string>
        </test>
        <test name="family">
          <string>system-ui</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK JP</string>
        </edit>
      </match>

      <!-- Korean -->
      <!-- "lang=ko" or "lang=ko-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>ko</string>
        </test>
        <test name="family">
          <string>system-ui</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK KR</string>
        </edit>
      </match>

      <!-- Chinese -->
      <!-- "lang=zh" or "lang=zh-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh</string>
        </test>
        <test name="family">
          <string>system-ui</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK SC</string>
        </edit>
      </match>
      <!-- "lang=zh-hans" or "lang=zh-hans-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-hans</string>
        </test>
        <test name="family">
          <string>system-ui</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK SC</string>
        </edit>
      </match>
      <!-- "lang=zh-hant" or "lang=zh-hant-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-hant</string>
        </test>
        <test name="family">
          <string>system-ui</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK TC</string>
        </edit>
      </match>
      <!-- "lang=zh-hant-hk" or "lang=zh-hant-hk-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-hant-hk</string>
        </test>
        <test name="family">
          <string>system-ui</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK HK</string>
        </edit>
      </match>
      <!-- Compatible -->
      <!-- "lang=zh-cn" or "lang=zh-cn-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-cn</string>
        </test>
        <test name="family">
          <string>system-ui</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK SC</string>
        </edit>
      </match>
      <!-- "lang=zh-tw" or "lang=zh-tw-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-tw</string>
        </test>
        <test name="family">
          <string>system-ui</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK TC</string>
        </edit>
      </match>
      <!-- "lang=zh-hk" or "lang=zh-hk-*" -->
      <match target="pattern">
        <test name="lang" compare="contains">
          <string>zh-hk</string>
        </test>
        <test name="family">
          <string>system-ui</string>
        </test>
        <edit name="family" mode="append" binding="strong">
          <string>Noto Sans CJK HK</string>
        </edit>
      </match>
    </fontconfig>

## 字體的備用樣式集

某些字體通過 OpenType 功能為字符提供了可選的樣式集。

通常，這些樣式集被命名為 `ss0x`，包含針對單個字符的小更改。

以下示例演示如何將等寬版本 ttf-ibm-plex包 默認的虛線零更改為斜線零。

    ~/.config/fontconfig/fonts.conf

    <?xml version="1.0"?>
    <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
    <fontconfig>
        <match target='font'>
            <test name='fontformat' compare='not_eq'>
                <string/>
            </test>
            <test name='family'>
                <string>IBM Plex Mono</string>
            </test>
            <edit name='fontfeatures' mode='assign_replace'>
                <string>ss03</string>
            </edit>
        </match>
    </fontconfig>

查看 What are "Stylistic Sets?" 了解關於此的更多信息。

## 另請參閱

- Gentoo 論壇
- Ubuntu Wiki

分類：​

- 字體

字體配置/示例
新增話題