字体配置/示例
阅读主文章:字体配置。
配置可能一定程度上有所不同。请发布 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?" 了解关于此的更多信息。