Linux字体安装

Linux字体文件放在/usr/share/font/,只要将字体文件拷贝到这里就可以了。
这里示例安装Windows的所有字体。

1,新建路径存放字体库:/usr/share/fonts/
2,进入Windows下> 的字体库目录c:\windows\Fonts。复制字体库到创建好的字体库目录/usr/share/fonts/。
3,进入字体库目录,刷新系统即刻生效,输入命令:mkfontscale ; mkfontdir ; fc-cache。

一、查看系统字体
在开始安装之前,我们先查看系统中已经安装的字体。

要查看系统中已经安装的字体,我们可以使用fc-list命令进行查看。如果系统中没有该命令的话,我们需要先安装相关的软件包。

查看系统类型:cat /etc/issue

在centos上,使用如下命令进行安装:
yum install -y fontconfig mkfontscale

在ubuntu上,使用如下命令进行安装:
sudo apt-get -y install fontconfig xfonts-utils

查看系统默认字体:fc-list
如果要查看系统中已经安装的中文字体,我们可以使用如下命令:fc-list :lang=zh

二、安装字体
在centos上和ubuntu上安装字体方法都是一样的,我们只需要进行相关的操作即可。
把MSYH.TTF复制到/usr/share/fonts/目录下,使用rz,Xftp等方式都可以:

更新字体缓存,使用如下命令:
cd /usr/share/fonts/
mkfontscale
mkfontdir
fc-cache

[root@scm fonts]# cd /usr/share/fonts/
[root@scm fonts]# mkfontscale
[root@scm fonts]# mkfontdir
[root@scm fonts]# fc-cache -fv 
/usr/share/fonts: caching, new cache contents: 2 fonts, 0 dirs
/usr/share/X11/fonts/Type1: skipping, no such directory
/usr/share/X11/fonts/TTF: skipping, no such directory
/usr/local/share/fonts: skipping, no such directory
/root/.fonts: skipping, no such directory
/var/cache/fontconfig: cleaning cache directory
/root/.fontconfig: not cleaning non-existent cache directory
fc-cache: succeeded

---------------------------------------------------------------------

至此,字体已经安装完毕。
现在我们再来查看微软雅黑字体,是否安装成功,使用如下命令:

fc-list :lang=zh

[root@tonykorn97 fonts]# fc-list :lang=zh
华文彩云,STCaiyun:style=Regular
幼圆,YouYuan:style=Regular
华文琥珀,STHupo:style=Regular
方正姚体,FZYaoTi:style=Regular
新宋体,NSimSun:style=Regular
仿宋,FangSong:style=Normal,oby?ejné,Standard,Κανονικ?,Regular,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
楷体,KaiTi:style=Normal,oby?ejné,Standard,Κανονικ?,Regular,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
华文宋体,STSong:style=Regular
微软雅黑,Microsoft YaHei:style=Normal,oby?ejné,Standard,Κανονικ?,Regular,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
宋体,SimSun:style=Regular
华文仿宋,STFangsong:style=Regular
华文新魏,STXinwei:style=Regular
华文行楷,STXingkai:style=Regular
华文隶书,STLiti:style=Regular
黑体,SimHei:style=Normal,oby?ejné,Standard,Κανονικ?,Regular,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
华文中宋,STZhongsong:style=Regular
微软雅黑,Microsoft YaHei:style=Negreta,tu?né,fed,Fett,?ντονα,Bold,Negrita,Lihavoitu,Gras,Félk?vér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kal?n,Krepko,Lodia
方正舒体,FZShuTi:style=Regular
华文细黑,STXihei:style=Regular
隶书,LiSu:style=Regular
华文楷体,STKaiti:style=Regular

----------------------------------------------------------------------------

通过上图,我们可以很明显的看出微软雅黑字体已经成功安装。

部署中遇到的问题:
测试环境:部署完成没有重启jar包,程序里读取不出来字体库,重启服务器可以了,
生产环境:部署完成字体库,没有重启服务器,重启的jar包,程序读取出字体库了,
综合以上情况,先重启服务程序,最后如果都不行在启动服务器,别被其他的文章坑了。
安装yum install -y fontconfig mkfontscale 报错:

[root@VM-16-11-centos fonts]# yum install -y fontconfig mkfontscale
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-Epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Repository epel is listed more than once in the configuration
CentOS Linux 8 - AppStream                                                                                                                22  B/s |  38  B     00:01    
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
————————————————

解决办法:

# 进入yum.repos.d 目录下
cd /etc/yum.repos.d/
# 修改源链接
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
# 要将之前的mirror.centos.org 改成 vault.centos.org
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
————————————————




 

  • 10
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
Linux系统中,可以通过以下步骤来安装字体: 1. 将字体文件复制到/usr/share/fonts/目录下。你可以使用命令行或文件管理器来完成此操作。例如,将字体文件"MSYH.TTF"复制到/usr/share/fonts/目录下。 2. 确保你有适当的权限来复制文件。你可能需要使用sudo命令来获得管理员权限。 3. 安装字体配置工具和字体工具。在Ubuntu上,你可以使用以下命令来安装相关的软件包:sudo apt-get -y install fontconfig xfonts-utils。 4. 刷新字体缓存。在终端中运行以下命令以更新系统中已安装字体的缓存:sudo fc-cache -fv。 5. 现在,你的新字体应该已经安装成功了。你可以在应用程序中选择并使用这些字体。 需要注意的是,不同的Linux发行版可能会有一些细微的差异。上述步骤适用于大多数基于Debian的发行版,如Ubuntu。如果你使用的是其他发行版, 请参考相应的文档或官方网站来获取更准确的指导。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [Linux字体安装](https://blog.csdn.net/zw899004/article/details/127281518)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值