Linux 下安装中文字体

Linux 下安装中文字体,第1张

概述本文以安装黑体为例,简单演示如何在Linux下安装中文字体。 环境信息介绍 [[email protected] ~]# cat /etc/redhat-releaseCentOS Linux release 7.1.1503 (Core)[[email protected] ~]#[[email protected] ~]# uname -r3.10.0-229.el7.x86_64

本文以安装黑体为例,简单演示如何在linux下安装中文字体。

环境信息介绍
[[email protected] ~]# cat /etc/redhat-releaseCentOS linux release 7.1.1503 (Core)[[email protected] ~]#[[email protected] ~]# uname -r3.10.0-229.el7.x86_64[[email protected] ~]#[[email protected] ~]# echo $LANGen_US.UTF-8[[email protected] ~]# cat /etc/locale.confLANG="zh_CN.UTF-8"[[email protected] ~]#[[email protected] ~]# localeLANG=en_US.UTF-8LC_CTYPE="en_US.UTF-8"LC_NUMERIC="en_US.UTF-8"LC_TIME="en_US.UTF-8"LC_ColLATE="en_US.UTF-8"LC_MONETARY="en_US.UTF-8"LC_MESSAGES="en_US.UTF-8"LC_PAPER="en_US.UTF-8"LC_name="en_US.UTF-8"LC_ADDRESS="en_US.UTF-8"LC_TELEPHONE="en_US.UTF-8"LC_MEASUREMENT="en_US.UTF-8"LC_IDENTIFICATION="en_US.UTF-8"LC_ALL=[[email protected] ~]#
依赖的命令

*** 作依赖几个命令,如果系统中不存在需要手动安装下。

fc-List:列举可用的字体 fc-cache:生成字体信息的缓存

这两个命令包含在Fontconfig包里,可以通过下面的命令进行安装。

yum install Fontconfig
mkFontscale:生成字体索引

这个命令属于xorg-x11-Font-utils工具包,可以通过下面的命令进行安装。

yum install mkFontscale
*** 作步骤 创建一个用于存放中文字体的目录
mkdir /usr/share/Fonts/zh_CN

PS: /usr/share/Fonts/这个目录会在安装Fontconfig包之后自动创建

上传字体simhei.ttf到上述目录中

构建字体索引和缓存

mkFontscalemkFontdirfc-cache -fv

执行上述命令之后,在目录下可以看到一个Fonts.dir和一个Fonts.scale文件

[[email protected] zh_CN]# pwd/usr/share/Fonts/zh_CN[[email protected] zh_CN]# lltotal 9532-rw-r--r-- 1 root root      66 Sep  4 11:39 Fonts.dir-rw-r--r-- 1 root root      66 Sep  4 11:39 Fonts.scale-rwxrw-rw- 1 root root 9751960 Sep  4 11:38 simhei.ttf[[email protected] zh_CN]#

文件内容

[[email protected] zh_CN]# cat Fonts.dir1simhei.ttf -misc-simhei-medium-r-normal--0-0-0-0-p-0-iso10646-1[[email protected] zh_CN]# cat Fonts.scale1simhei.ttf -misc-simhei-medium-r-normal--0-0-0-0-p-0-iso10646-1[[email protected] zh_CN]#
查看字体
# 查看所有可用字体[[email protected] zh_CN]# fc-List/usr/share/Fonts/dejavu/DejaVuSansCondensed-Oblique.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Oblique,Oblique/usr/share/Fonts/dejavu/DejaVuSansCondensed-Bold.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Bold,Bold/usr/share/Fonts/dejavu/DejaVuSans.ttf: DejaVu Sans:style=Book/usr/share/Fonts/zh_CN/simhei.ttf: SimHei:style=Regular,normal/usr/share/Fonts/dejavu/DejaVuSans-Bold.ttf: DejaVu Sans:style=Bold/usr/share/Fonts/dejavu/DejaVuSansCondensed.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed,Book/usr/share/Fonts/dejavu/DejaVuSans-Extralight.ttf: DejaVu Sans,DejaVu Sans light:style=Extralight/usr/share/Fonts/dejavu/DejaVuSansCondensed-Boldoblique.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Bold Oblique,Bold Oblique/usr/share/Fonts/dejavu/DejaVuSans-Oblique.ttf: DejaVu Sans:style=Oblique/usr/share/Fonts/dejavu/DejaVuSans-Boldoblique.ttf: DejaVu Sans:style=Bold Oblique[[email protected] zh_CN]## 只查看中文字体,SimHei字体安装成功。[[email protected] zh_CN]# fc-List :lang=zh/usr/share/Fonts/zh_CN/simhei.ttf: SimHei:style=Regular,normal[[email protected] zh_CN]#
总结

以上是内存溢出为你收集整理的Linux 下安装中文字体全部内容,希望文章能够帮你解决Linux 下安装中文字体所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/yw/1024330.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存