Skip to content

Instantly share code, notes, and snippets.

@allex
Last active June 3, 2024 13:32
Show Gist options
  • Save allex/11203573 to your computer and use it in GitHub Desktop.
Save allex/11203573 to your computer and use it in GitHub Desktop.
Ubuntu 安装中文字体

环境 (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:

@xmfbit
Copy link

xmfbit commented Jan 5, 2022

谢谢

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