欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

程序员文章站 2022-06-05 18:37:54
...

不多BB了,直接上步骤

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

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

2. 安装fontconfig
[[email protected] share]# yum -y install fontconfig
Loaded plugins: fastestmirror
...
...
...
Complete!

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

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

链接: simsun.zip.
密码:8c4j
百度云盘的下载地址。。。好吧!没有其他网盘了,不要在意这些细节文件也不是特别大-_-。

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

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

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

[[email protected] 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
[email protected] 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. 最后保存文件并执行命令进行刷新字体缓存,查看现有的字体列表
[[email protected] fonts]# fc-cache
[[email protected] fonts]# fc-list | grep "宋"
NSimSun,新宋体:style=Regular
SimSun\-PUA,宋体\-PUA:style=Regular
SimSun,宋体:style=Regular

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

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

相关标签: Linux笔记