Graphics2D 打包在Linux运行时中文乱码,展示成方格

news/2024/10/18 12:05:13/

项目打jar包在服务器运行时,生成的图片中文全是方格,因为Linux上没有对应的字体文件,

安装字体文件

1、在本地Windows电脑上C:\Windows\Fonts 下面的字体文件全部复制,也可以单独复制需要的字体,复制后要删除所有的不是ttc、ttf的文件,不然无法执行安装命令

2、在服务器新建文件夹来存放字体文件 例如 /usr/local/share/fonts

cd  /usr/local/share
mkdir fonts

3、然后进入该目录,依次执行以下命令

mkfontscale // 安装字体
mkfontdir 
fc-cache // 更新字体

执行完后可通过 fc-list命令查看当前系统具有的字体,接下来重启jar包就可以了!

执行命令如果报错 

-bash: mkfontscale: command not found  ,

 -bash: fc-cache: command not found

需要安装mkfontscale、fontconfig

yum install mkfontscale yum install fontconfig

5、在安装mkfontscale时报错

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below wiki article https://wiki.centos.org/yum-errorsIf above article doesn't help to resolve this issue please use https://bugs.centos.org/.One of the configured repositories failed (CentOS-7 - Base),and yum doesn't have enough cached data to continue. At this point the onlysafe thing yum can do is fail. There are a few ways to work "fix" this:1. Contact the upstream for the repository and get them to fix the problem.2. Reconfigure the baseurl/etc. for the repository, to point to a workingupstream. This is most often useful if you are using a newerdistribution release than is supported by the repository (and thepackages for the previous distribution release still work).3. Run the command with the repository temporarily disabledyum --disablerepo=base ...4. Disable the repository permanently, so yum won't use it by default. Yumwill then just ignore the repository until you permanently enable itagain or use --enablerepo for temporary usage:yum-config-manager --disable baseorsubscription-manager repos --disable=base5. Configure the failing repository to be skipped, if it is unavailable.Note that yum will try to contact the repo. when it runs most commands,so will have to try and fail each time (and thus. yum will be be muchslower). If it is a very temporary problem though, this is often a nicecompromise:yum-config-manager --save --setopt=base.skip_if_unavailable=truefailure: repodata/repomd.xml from base: [Errno 256] No more mirrors to try.
https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found

这个时候就不要想起他的了,反正我是搞了一天,最后直接rm了/etc/yum.repos.d 下面的所有文件,也就是按照文档说的换yum源,不过换源前建议还是备份一下比较好

cp -r /etc/yum.repos.d/ /etc/yum.repos.d.bf

3、通过wget进行下载在线yum源

cd /etc/yum.repos.d/

阿里云地址

wget http://mirrors.aliyun.com/repo/Centos-7.repo 

下载完成后会看到 Centos-7.repo 文件,然后再次执行mkfontscale的安装,继续上面的字体安装步骤


http://www.ppmy.cn/news/1539994.html

相关文章

滚雪球学Redis[8.2讲]:Redis的未来发展趋势:从云服务到AI与物联网的前沿探索

全文目录: 🎉前言🔄Redis在云服务中的应用🪁1. Redis作为云缓存服务🪄示例:使用AWS ElastiCache Redis实例 🎮️2. 云原生应用中的持久化与高可用 ⚙️Redis 6.x及后续版本的新特性&#x1f579…

Star Tower:智能合约的安全基石与未来引领者

在区块链技术的快速发展中,智能合约作为新兴的应用形式,正逐渐成为区块链领域的重要组成部分。然而,智能合约的可靠性问题一直是用户最为关心的焦点之一。为此,Star Tower以其强大的技术实力和全面的安全保障措施,为智…

奥比中光opencv显示可见光图片

在奥比中光提供的sdk中没有直接使用opencv读取显示视频流的功能,参照案例与代码写了一个opencv显示奥比中光可见光流的cpp代码 代码: #include "libobsensor/hpp/Pipeline.hpp" #include "libobsensor/hpp/Error.hpp"const char *m…

【AIGC】AI如何匹配RAG知识库: Embedding实践,语义搜索

引言 RAG作为减少模型幻觉和让模型分析、回答私域相关知识最简单高效的方式,我们除了使用之外可以尝试了解其是如何实现的。在实现RAG的过程中Embedding是非常重要的手段。本文将带你简单地了解AI工具都是如何通过Embedding去完成语义分析匹配的。 Embedding技术简…

第三季度中国游戏市场收入创历史新高;京东物流与淘宝天猫达成合作;YouTube 上线“用相机拍摄”标签....|网易数智日报

第三季度中国游戏市场收入917.66亿,创历史新高 中国音数协游戏工委今日发布了最新的 2024 年第三季度中国游戏产业季度报告。 数据显示,2024 年第三季度中国游戏市场收入 917.66 亿元,环比增长 22.96%,同比增长 8.95%。 中国音…

智联云采 SRM2.0 testService SQL注入漏洞复现

0x01 产品简介 智联云采是一款针对企业供应链管理难题及智能化转型升级需求而设计的解决方案,针对企业供应链管理难题,及智能化转型升级需求,智联云采依托人工智能、物联网、大数据、云等技术,通过软硬件系统化方案,帮助企业实现供应商关系管理和采购线上化、移动化、智能…

在 WPF 中使用 OpenTK:从入门到进阶

一、引言 WPF(Windows Presentation Foundation)是微软推出的用于创建丰富的桌面应用程序用户界面的框架。OpenTK 则为我们提供了强大的图形处理能力,包括 3D 图形渲染、数学计算等功能。将两者结合起来,可以在 WPF 应用程序中实…

兰迪·舍克曼担任生命银行链(LBC)顾问,赋能基因数据技术发展

兰迪舍克曼(Randy Schekman)作为生命银行链(Life Bank Chain, LBC)的顾问参与其中,这无疑是个令人兴奋的消息!他在生理医学和基因研究方面拥有深厚的专业知识,必将对LBC的使命,即安全…