Skip to content

Instantly share code, notes, and snippets.

@erain
Forked from allex/gist:11203573
Last active June 24, 2023 05:36
Show Gist options
  • Save erain/0c13b452f7104e6a4b83 to your computer and use it in GitHub Desktop.
Save erain/0c13b452f7104e6a4b83 to your computer and use it in GitHub Desktop.

环境 (Environment)

版本:Ubuntu 14.04 LTS 默认语言:English(United States)

安装 (Setup)

Debian 和 Ubuntu 下对中文支持比较好的字体有: fonts-droid、ttf-wqy-zenhei 和 ttf-wqy-microhei 等,除了文泉驿系列字体外,比较流行的免费中文字体还有文鼎提供的楷体和上海宋,包名分别是: fonts-arphic-ukai 和 fonts-arphic-uming。

sudo apt-get install fonts-droid ttf-wqy-zenhei ttf-wqy-microhei fonts-arphic-ukai fonts-arphic-uming

注: 系统字体可以手动安装, /usr/share/fonts/

在/etc/fonts/conf.d 里面加上3 个文件的链接:

cd /etc/fonts/conf.d/
sudo ln -s /etc/fonts/conf.avail/69-language-selector-zh-cn.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>

    <match target="pattern">
        <test name="lang">
            <string>zh-cn</string>
        </test>
        <test qual="any" name="family">
            <string>serif</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>WenQuanYi Micro Hei</string>
            <string>AR PL UMing CN</string>
            <string>AR PL UMing HK</string>
            <string>AR PL New Sung</string>
            <string>WenQuanYi Bitmap Song</string>
            <string>AR PL UKai CN</string>
            <string>AR PL ZenKai Uni</string>
            <string>HYSong</string>
        </edit>
    </match> 
    <match target="pattern">
        <test qual="any" name="family">
            <string>sans-serif</string>
        </test>
        <test name="lang">
            <string>zh-cn</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>WenQuanYi Micro Hei</string>
            <string>Droid Sans Fallback</string>
            <string>HYSong</string>
            <string>AR PL UMing CN</string>
            <string>AR PL UMing HK</string>
            <string>AR PL New Sung</string>
            <string>AR PL UKai CN</string>
            <string>AR PL ZenKai Uni</string>
        </edit>
    </match> 
    <match target="pattern">
        <test qual="any" name="family">
            <string>monospace</string>
        </test>
        <test name="lang">
            <string>zh-cn</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>WenQuanYi Micro Hei Mono</string>
            <string>Droid Sans Fallback</string>
            <string>HYSong</string>
            <string>AR PL UMing CN</string>
            <string>AR PL UMing HK</string>
            <string>AR PL New Sung</string>
            <string>AR PL UKai CN</string>
            <string>AR PL ZenKai Uni</string>
        </edit>
    </match> 

</fontconfig>

最后更新字体缓存, 注销重新登陆

sudo fc-cache -f -v

(Optional) 设置系统字体

gconf-editor

  • 应用程序字体:/desktop/gnome/interface/font_name
  • 文档字体:/desktop/gnome/interface/document_font_name
  • 桌面字体:/apps/nautilus/preferences/desktop_font
  • 窗口标题字体:/apps/metacity/general/titlebar_font
  • 等宽字体:/desktop/gnome/interface/monospace_font_name

References:

@DIYer22
Copy link

DIYer22 commented Sep 3, 2019

请问, ubuntu 下有自带的默认中文字体吗? 我找了好久, 都没有搜索到相关信息

@erain
Copy link
Author

erain commented Sep 3, 2019

请问, ubuntu 下有自带的默认中文字体吗? 我找了好久, 都没有搜索到相关信息

根据这篇博客,16.04的默认字体是NOTO CJK。简单来说就是查看/etc/fonts/conf.d/64-language-selector-prefer.conf 文件。

@DIYer22
Copy link

DIYer22 commented Sep 3, 2019

回复及时, 太感谢了!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment