linux fontconfig 中文字体配置

编写于

用了几年的配置,备份下,也顺道共享出来:)
之前曾经发在 linuxsir.org 上.




<?xml version=‘1.0’?>
<!DOCTYPE fontconfig SYSTEM ‘fonts.dtd’>
<fontconfig>
<!– AA效果 –>
<match target=“font”>
<edit name=“hinting”>
<bool>true</bool>
</edit>
<edit name=“hintstyle”>
<const>hintslight</const>
</edit>
<edit name=“autohint”>
<bool>true</bool>
</edit>
<edit name=“antialias”>
<bool>true</bool>
</edit>
</match>
<!– 小于9号的中文字,使用WQY微米字体
<match>
<test compare=“eq” name=“lang” qual=“any”>
<string>zh</string>
<string>zh-cn</string>
<string>zh-tw</string>
</test>
<test compare=“less_eq” name=“size”>
<double>9</double>
</test>
<edit mode=“assign” name=“family”>
<string>WenQuanYi Micro Hei Mono</string>
</edit>
</match> –>
<!– 使用微软雅黑来替代中文粗体 –>
<match>
<test compare=“more” name=“weight”>
<const>medium</const>
</test>
<test compare=“eq” name=“lang” qual=“any”>
<string>zh</string>
<string>zh-cn</string>
<string>zh-tw</string>
</test>
<test compare=“more” name=“size”>
<double>9</double>
</test>
<edit mode=“assign” name=“family”>
<string>YaHei Consolas Hybrid</string>
<!– <string>Microsoft YaHei</string> –>
</edit>
</match>
<!–
The dual-width Asian fonts (spacing=dual) are not rendered correctly,
apparently FreeType forces all widths to match. Trying to disable the
width forcing code by setting globaladvance=false alone doesn’t help.
As a brute force workaround, also set spacing=proportional, i.e. handle
them as proportional fonts:
–>
<match>
<test compare=“contains” name=“lang”>
<string>zh</string>
<string>ja</string>
<string>ko</string>
</test>
<test compare=“eq” name=“spacing”>
<const>dual</const>
</test>
<edit mode=“assign” name=“spacing”>
<const>proportional</const>
</edit>
<edit mode=“assign” name=“globaladvance”>
<bool>false</bool>
</edit>
</match>
<!–
字体别名

中文待选:
Adobe Fangsong Std R
Adobe Heiti Std
Adobe Song Std
Adobe Ming Std
Microsoft YaHei
WenQuanYi Zen Hei Mono
WenQuanYi Zen Hei Sharp
WenQuanYi Bitmap Song
WenQuanYi Micro Hei
–>
<alias>
<family>serif</family>
<prefer>
<family>Liberation Serif</family>
<family>DejaVu Serif</family>
<family>Bitstream Vera Serif</family>
<family>Adobe Song Std</family>
<family>WenQuanYi Bitmap Song</family>
</prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer>
<family>Liberation Sans</family>
<family>DejaVu Sans</family>
<family>Bitstream Vera Sans</family>
<family>YaHei Consolas Hybrid</family>
<!– <family>Microsoft YaHei</family> –>
<family>WenQuanYi Zen Hei Mono</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>Liberation Mono</family>
<family>DejaVu Sans Mono</family>
<family>Bitstream Vera Sans Mono</family>
<family>WenQuanYi Zen Hei Mono</family>
</prefer>
</alias>
<!–
为没有安装的字体映射
–>
<match target=“pattern”>
<test name=“family”>
<!– <string>PMingLiU</string>
<string>MingLiU</string> –>
<string>FangSong_GB2312</string>
<string>KaiTi_GB2312</string>
<string>AR PL KaitiM GB</string>
<string>AR PL KaitiM Bit5</string>
<string>AR PL SungtiL GB</string>
<string>AR PL Mingti2L Bit5</string>
<string>AR PL ShanHeiSun Uni</string>
<string>AR PL ZenKai Uni</string>
<string>MS 明朝</string>
<string>MS ゴシック</string>
<string>Kochi Mincho</string>
<string>Kochi Gothic</string>
<string>Baekmuk Batang</string>
<string>Baekmuk Dotum</string>
<string>Baekmuk Gulim</string>
<string>Baekmuk Headline</string>
</test>
<edit mode=“assign” name=“family”>
<string>sans-serif</string>
</edit>
</match>
<include ignore_missing=“yes”>~/.fonts.vista.conf</include>
<dir>~/.fonts</dir>
<match target=“font”>
<edit mode=“assign” name=“rgba”>
<const>none</const>
</edit>
</match>
<match target=“font”>
<edit mode=“assign” name=“hinting”>
<bool>true</bool>
</edit>
</match>
<match target=“font”>
<edit mode=“assign” name=“hintstyle”>
<const>hintmedium</const>
</edit>
</match>
<match target=“font”>
<edit mode=“assign” name=“antialias”>
<bool>true</bool>
</edit>
</match>
</fontconfig>