fonts.conf
~/.fonts.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="pattern">
<test qual="any" name="family">
<string>sans-serif</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>DejaVu Sans</string>
<string>WenQuanYi Micro Hei</string>
<string>WenQuanYi Zen Hei</string>
<string>AR PL UMing CN</string>
<string>AR PL UKai CN</string>
</edit>
</match>
<match target="pattern">
<test qual="any" name="family">
<string>serif</string>
</test>
<edit name="family" mode="prepend" binding="strong">
<string>DejaVu Serif</string>
<string>WenQuanYi Micro Hei</string>
<string>WenQuanYi Zen Hei</string>
<string>AR PL UMing CN</string>
<string>AR PL UKai CN</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>
<string>WenQuanYi Micro Hei Mono</string>
<string>WenQuanYi Zen Hei</string>
<string>AR PL UMing CN</string>
<string>AR PL UKai CN</string>
</edit>
</match>
</fontconfig>
我原先使用alias来调整字体的优先级,如:
<alias>
<family>sans-serif</family>
<prefer>
<family>DejaVu Sans</family>
<family>WenQuanYi Micro Hei</family>
</prefer>
</alias>
但是使用alias无法指定字体的binding,而默认的binding为weak,这种情况下lang的优先级比font family高,导致在中文环境下(zh_CN),使用sans-serif字体的英文字符也匹配成了WenQuanYi Micro Hei字体(dejavu的lang属性不包含zh)。
用<edit name="family" mode="prepend" binding="strong">使字体的binding为strong,这样其font family优先级高于lang,就会使使用sans-serif字体的英文字符匹配为DejaVu Sans。
参考:
fonts-conf "Font Matching" section.
工具: