1:安装字体库(在CentOS 4.x开始用fontconfig来安装字体库):
yum -y install fontconfig
这时在/usr/shared目录就可以看到fonts和fontconfig目录
2:获取字体文件:
网上下载并解压 或 在Windows的c盘下的Windows/Fonts目录复制并上传,在/usr/share/fonts/下建一个chinese/文件夹,并将字体文件放于此处。
# 创建目录
mkdir /usr/share/fonts/chinese
# 放入字体文件
...
# 修改目录权限
chmod -R 755 /usr/share/fonts/chinese
3:生成字库索引信息(centos8好像把字体文件复制到位就能用了?——按常规步骤有两种方法:用ttmkfdir 或 mkfontdir和mkfontscale)
(1)mkfontdir和mkfontscale
//在/usr/share/fonts/chinese执行命令,生成字库索引信息 :
mkfontscale
mkfontdir
(2)ttmkfdir
# 安装ttmkfdir
yum -y install ttmkfdir
# 创建所有信息
ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir
# 手动修改配置信息,可以看到一个Font list,即字体列表,在这里需要把我们添加的中文字体位置加进去
# 可能不需要,因为其配置文件本身包含了/use/share/fonts,其下的chinese文件夹应该能起作用。
vim /etc/fonts/fonts.conf
(准备生成onts.dir 和fonts.scale。Slackware自带的是mkfontdir和mkfontscale,据源教程,不推荐这两个工具,它们生成的fonts.dir很不爽,simsun.ttf里找不出gbk的encoding。推荐ttmkfdir)
REF:https://www.phpfans.net/ask/fansa1/8474748286.html
4:更新字体缓存:(刷新内存中的字体缓存,这样就不用reboot重启了)
# 刷新内存中的字体缓存
fc-cache –fv
# 执行以下命令让字体生效
source /etc/profile
# 查看系统安装字体(仅看中文)
fc-list (fc-list :lang=zh-cn)
简单安装单用户字体库:
安装 字体库 到用户目录下的.fonts文件夹:
sudo yum groupinstall "fonts"
安装 source-code-pro 字体
下载ZIP包:sudo wget https://github.com/downloads/adobe-fonts/source-code-pro/SourceCodePro_FontsOnly-1.013.zip
解压:sudo unzip SourceCodePro_FontsOnly-1.013.zip
创建目录:sudo mkdir ~/.fonts
拷贝字体:sudo cp ./SourceCodePro_FontsOnly-1.013/OTF/* ~/.fonts/
生成新的字体缓存:fc-cache -f -v
//最少仅用以上3步
原文链接:https://blog.csdn.net/Web_Rookie_Xun/article/details/79894904