6 Star 72 Fork 28

JustryDeng / notebook

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
[07]CentOS7增加系统字体.md 2.75 KB
Copy Edit Raw Blame History
JustryDeng authored 2023-04-04 16:36 . 部署jianmu

CentOS7增加系统字体

准备字体文件

  • 方式一:去windows(C:\Windows\Fonts)下找到想用的字体,复制并修改后缀名为ttc

    1660026012243

  • 方式二:去网上下载对应的ttc字体文件

CentOS7增加系统字体

第一步:查看已有字体

# 若提示指令不存在,则执行指令进行安装 yum -y install fontconfig
fc-list

注:安装了fontconfig后,在/usr/share目录可以查看到fonts 和fontconfig目录

1660026570159

第二步:将字体复制进linux对应目录

创建/usr/share/fonts/chinese目录

mkdir -p /usr/share/fonts/chinese
cd /usr/share/fonts/chinese

下载对应的字体文件,如微软雅黑

image-20230404090546451

注:windows系统的话,可以直接去C:\Windows\Fonts找到该字体文件

将字体文件放入/usr/share/fonts/chinese下

1660028192002

给该目录加 755 权限

chmod -R 755 /usr/share/fonts/chinese

1660028233313

第三步:安装ttmkfdir

ttmkfdir是用来搜索目录中所有的字体信息,并汇总生成fonts.scale文件的

# 安装ttmkfdir
yum -y install ttmkfdir
# 执行相关指令,搜索目录中所有的字体信息,并汇总生成fonts.scale文件的
ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir

1660028341051

第四步:修改字体配置文件,添加字体库文件夹

将字体目录/usr/share/fonts/chinese加入到/etc/fonts/fonts.conf配置文件,添加以下内容

编辑

vim /etc/fonts/fonts.conf

添加

<dir>/usr/share/fonts/chinese</dir>

添加完后可以查看一下

cat /etc/fonts/fonts.conf | grep -C3 chinese

1660028668322

第五步:刷新内存中的字体缓存

fc-cache
fc-list

可看到我们添加的字体【微软雅黑】已经成功添加进去了

1660028959705

1
https://gitee.com/JustryDeng/notebook.git
git@gitee.com:JustryDeng/notebook.git
JustryDeng
notebook
notebook
master

Search