Centos7 Fonts Install & Configuration

1. Environment

  • 下载字体(宋体、黑体)

    Windows系统中有

  • NAS地址

    公共资源 > Tools > Fonts> Dev_software

2. Install

  • 安装字体库

    yum -y install fontconfig
    
    yum -y install ttmkfdir
    
  • 这时在/usr/share目录就可以看到fonts和fontconfig目录了(之前是没有的)

    cd /usr/share
    ll
    
  • 添加中文字体,新建目录

    cd /usr/share/fonts
    ll
    mkdir chinese
    ll
    
  • 将字体上传至该目录

  • 赋予chinese目录的权限

    chmod -R 755 /usr/share/fonts/chinese
    
  • 执行ttmkfdir命令

    ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir
    
  • 最后一步就是修改字体配置文件

    vi /etc/fonts/fonts.conf
    
  • 修改内容如下

    <!-- Font directory list -->
    <dir>/usr/share/fonts</dir>
    <dir>/usr/share/X11/fonts/Type1</dir> 
    <dir>/usr/share/X11/fonts/TTF</dir> 
    <dir>/usr/local/share/fonts</dir>
    <dir>/usr/share/chinese/fonts</dir> #添加改行
    <dir prefix="xdg">fonts</dir>
    <!-- the following element will be removed in the future -->
    <dir>~/.fonts</dir>
    
  • 输入:wq保存退出,最后别忘了刷新内存中的字体缓存,这样就不用reboot重启

    fc-cache
    
  • 通过fc-list看一下字体列表

    fc-list