加载中...

Centos、Ubuntu 安装中文字体

正文

linux相关命令:

# 查看已安装的中文字体
fc-list :lang=zh

# 查看已安装的中文字体并排序
fc-list :lang=zh-cn | sort

一.Centos系列

1.安装字体库

yum -y install fontconfig

2.添加中文字体,建立存储中文字体的文件夹

mkdir /usr/share/fonts/chinese

3.在windows上打开c盘下的Windows/Fonts目录,选择你喜欢的字体,后缀名ttf和ttc(如果有)的文件,将中文字体上传到Linux中那个chinese文件夹中
我这里做了几个字体的远程下载链接,可以直接通过 wget 下载到你的系统中,减少了上传的麻烦

微软雅黑:
https://shuiche-shop.oss-cn-chengdu.aliyuncs.com/fonts/msyhl.ttc
https://shuiche-shop.oss-cn-chengdu.aliyuncs.com/fonts/msyh.ttc
https://shuiche-shop.oss-cn-chengdu.aliyuncs.com/fonts/msyhbd.ttc
仿宋:
https://shuiche-shop.oss-cn-chengdu.aliyuncs.com/fonts/simfang.ttf
宋体:
https://shuiche-shop.oss-cn-chengdu.aliyuncs.com/fonts/simsun.ttc

4.修改chinese目录的权限:

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

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

yum -y install ttmkfdir

6.接下来生成

ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir

7.修改字体配置文件

vi /etc/fonts/fonts.conf

将中文字体文件夹目录添加到配置文件中

8.最后刷新内存中的字体缓存,这样就不用reboot重启了:

fc-cache
  1. 检查中文字体是否被添加进去
fc-list

可以看到有中文字体打印出来了

二.Ubuntu系列

Ubuntu对软件包的支持很大力

# 文泉驿黑体
apt install ttf-wqy-zenhei
apt install fonts-wqy-microhei
posted @ 2022-11-28 23:14  水车  阅读(1464)  评论(0编辑  收藏  举报