关于Linux服务器中文字体的安装

不多BB了,直接上步骤

1. 查看当前服务器字体列表
[root@iZ2zebt4cnbrfax6eu61s3Z ~]# fc-list
-bash: fc-list: command not found

返回结果为上述情况表示服务器没有字体库

2. 安装fontconfig
[root@iZ2zebt4cnbrfax6eu61s3Z share]# yum -y install fontconfig
Loaded plugins: fastestmirror
...
...
...
Complete!

安装完成后会在/usr/share目录下出现fonts和fontconfig两个文件夹

3. 下载对应宋体的字体文件simsun.zip上传至服务器

链接: simsun.zip.
密码:8c4j

以上链接清理网盘的时候手贱给删除了o(╥﹏╥)o,以下是新的链接地址:
链接:simsun.zip
提取码:fwv3
百度云盘的下载地址。。。好吧!没有其他网盘了,不要在意这些细节文件也不是特别大-_-。

4. 创建目录字体文件夹并将字体文件上传到文件夹中
[root@iZ2zebt4cnbrfax6eu61s3Z ~]# cd /usr/share/fonts
[root@iZ2zebt4cnbrfax6eu61s3Z fonts]# mkdir chinese

至于怎么上传就不多说了,我是用FinalShell上传的有兴趣可以去下载用用,这里提供Mac版的安装命令参考.

5. 修改创建的目录文件夹的权限
[root@iZ2zebt4cnbrfax6eu61s3Z fonts]# chmod -R 755 /usr/share/fonts/chinese
6. 安装ttmkfdir并生成fonts.scale文件
[root@iZ2zebt4cnbrfax6eu61s3Z fonts]# yum -y install ttmkfdir
[root@iZ2zebt4cnbrfax6eu61s3Z fonts]# ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir

[root@iZ2zebt4cnbrfax6eu61s3Z chinese]# ll
total 20528
-rw-r--r-- 1 root root     1030 Dec 24 09:49 fonts.scale
-rwxr-xr-x 1 root root 10512288 Dec 24 09:45 simsun.ttc
-rwxr-xr-x 1 root root 10499104 Dec 24 09:45 simsun.ttf
7. 修改字体配置文件,新增自定义的字体文件位置/usr/share/fonts/chinese
root@iZ2zebt4cnbrfax6eu61s3Z fonts]# vi /etc/fonts/fonts.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts/fonts.conf file to configure system font access -->
<fontconfig>

<!--
        DO NOT EDIT THIS FILE.
        IT WILL BE REPLACED WHEN FONTCONFIG IS UPDATED.
        LOCAL CHANGES BELONG IN 'local.conf'.

        The intent of this standard configuration file is to be adequate for
        most environments.  If you have a reasonably normal environment and
        have found problems with this configuration, they are probably
        things that others will also want fixed.  Please submit any
        problems to the fontconfig bugzilla system located at fontconfig.org

        Note that the normal 'make install' procedure for fontconfig is to
        replace any existing fonts.conf file with the new version.  Place
        any local customizations in local.conf which this file references.

        Keith Packard
-->

<!-- 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>~/.fonts</dir>
        <!--  在这在这在这在这在这在这在这在这在这加入/usr/share/fonts/chinese -->
        <dir>/usr/share/fonts/chinese</dir>

<!--
  Accept deprecated 'mono' alias, replacing it with 'monospace'
-->
        <match target="pattern">
"/etc/fonts/fonts.conf" 152L, 5369C
8. 最后保存文件并执行命令进行刷新字体缓存,查看现有的字体列表
[root@iZ2zebt4cnbrfax6eu61s3Z fonts]# fc-cache
[root@iZ2zebt4cnbrfax6eu61s3Z fonts]# fc-list | grep "宋"
NSimSun,新宋体:style=Regular
SimSun\-PUA,宋体\-PUA:style=Regular
SimSun,宋体:style=Regular

这样安装就完成,如果项目里面不生效重启项目即可

以上为个人总结的一些笔记,若有雷同纯属巧合,若有错误欢迎指出,谢谢!

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值