背景:润乾报表 win上面的项目直接上传到linux 上,但预览&下载报表时乱码

如果含有斜线的单元格或统计图的报表在网页上发布时,统计图或斜线单元格里的汉字会变成小方框,此时往往是服务器端操作系统的中文安装包没有装全,导致报表里用到的字体在服务器端的操作系统里找不到,因此成了小方块。

我这只配置到前 5 步就可以了,不需要重启Linux 或字体服务,步骤总结为以下:

1、检查字体是否已经安装:

fc-list  ----------检查所有已有的字体

fc-list :lang=zh -----------只检查中文

2、到 C:\windows\fonts 复制对应字体库,微软雅黑、宋体、黑体等,各文件后缀可能不一样,有的为ttf,有的为ttc,不影响使用。

3、上传刚才复制的字体库到/usr/share/fonts/zh_CN目录下,如果没有该目录,用命令:

mkdir /usr/share/fonts/zh_CN

来创建,然后再上传。

4、修改字体权限,使root以外的用户可以使用这些字体:使用777 赋予全部权限

chmod -R 777 /usr/share/fonts/zh_CN

5、建立字体缓存:

root@gxx:/usr/share/fonts# mkfontscale

root@gxx:/usr/share/fonts# mkfontdir

root@gxx:/usr/share/fonts# fc-cache -fv

/usr/share/fonts: caching, new cache contents: 0 fonts, 4 dirs

/usr/share/fonts/X11: caching, new cache contents: 0 fonts, 2 dirs

/usr/share/fonts/X11/encodings: caching, new cache contents: 0 fonts, 1 dirs

/usr/share/fonts/X11/encodings/large: caching, new cache contents: 0 fonts, 0 dirs

/usr/share/fonts/X11/util: caching, new cache contents: 0 fonts, 0 dirs

/usr/share/fonts/cmap: caching, new cache contents: 0 fonts, 5 dirs

/usr/share/fonts/cmap/adobe-cns1: caching, new cache contents: 0 fonts, 0 dirs

/usr/share/fonts/cmap/adobe-gb1: caching, new cache contents: 0 fonts, 0 dirs

/usr/share/fonts/cmap/adobe-japan1: caching, new cache contents: 0 fonts, 0 dirs

/usr/share/fonts/cmap/adobe-japan2: caching, new cache contents: 0 fonts, 0 dirs

/usr/share/fonts/cmap/adobe-korea1: caching, new cache contents: 0 fonts, 0 dirs

/usr/share/fonts/truetype: caching, new cache contents: 0 fonts, 1 dirs

/usr/share/fonts/truetype/dejavu: caching, new cache contents: 21 fonts, 0 dirs

/usr/share/fonts/zh_CN: caching, new cache contents: 419 fonts, 0 dirs

/usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs

/root/.local/share/fonts: skipping, no such directory

/root/.fonts: skipping, no such directory

Re-scanning /usr/share/fonts: caching, new cache contents: 0 fonts, 4 dirs

Re-scanning /usr/share/fonts/X11: caching, new cache contents: 0 fonts, 2 dirs

Re-scanning /usr/share/fonts/X11/encodings: caching, new cache contents: 0 fonts, 1 dirs

Re-scanning /usr/share/fonts/cmap: caching, new cache contents: 0 fonts, 5 dirs

Re-scanning /usr/share/fonts/truetype: caching, new cache contents: 0 fonts, 1 dirs

/var/cache/fontconfig: cleaning cache directory

/root/.cache/fontconfig: not cleaning non-existent cache directory

/root/.fontconfig: not cleaning non-existent cache directory

fc-cache: succeeded

6、重启 Tomcat,以上文章中有的说要重启 Linux系统,有的说要重启字体库服务,但我都没有,而且也没有字体服务,只是重启了Tomcat 执行后有效。

7、可以再次使用 fc-list 查看字体库,已经包含了新加入的字体,或者使用上边的Java 输出也包含了新字体,打印中文水印也OK。

root@gxx:~# fc-list :lang=zh

/usr/share/fonts/zh_CN/msyhl.ttc: Microsoft YaHei UI,Microsoft YaHei UI Light:style=Light,Regular

/usr/share/fonts/zh_CN/Dengl.ttf: DengXian,等线,DengXian Light,等线 Light:style=Light,Regular

/usr/share/fonts/zh_CN/msyh.ttc: Microsoft YaHei UI:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta

/usr/share/fonts/zh_CN/simsun.ttc: SimSun,宋体:style=Regular,常规

/usr/share/fonts/zh_CN/Dengb.ttf: DengXian,等线:style=Bold

/usr/share/fonts/zh_CN/SIMLI.TTF: LiSu,隶书:style=Regular

/usr/share/fonts/zh_CN/Deng.ttf: DengXian,等线:style=Regular

/usr/share/fonts/zh_CN/STXINWEI.TTF: STXinwei,华文新魏:style=Regular

/usr/share/fonts/zh_CN/STHUPO.TTF: STHupo,华文琥珀:style=Regular

/usr/share/fonts/zh_CN/msjhl.ttc: Microsoft JhengHei,微軟正黑體,微軟正黑體 Light,Microsoft JhengHei Light:style=Light,Regular

/usr/share/fonts/zh_CN/simkai.ttf: KaiTi,楷体:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta

/usr/share/fonts/zh_CN/STSONG.TTF: STSong,华文宋体:style=Regular

/usr/share/fonts/zh_CN/STFANGSO.TTF: STFangsong,华文仿宋:style=Regular

/usr/share/fonts/zh_CN/simhei.ttf: SimHei,黑体:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta

/usr/share/fonts/zh_CN/FZYTK.TTF: FZYaoTi,方正姚体:style=Regular

/usr/share/fonts/zh_CN/FZSTK.TTF: FZShuTi,方正舒体:style=Regular

/usr/share/fonts/zh_CN/msjh.ttc: Microsoft JhengHei,微軟正黑體:style=Normal,Regular,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta

/usr/share/fonts/zh_CN/STXINGKA.TTF: STXingkai,华文行楷:style=Regular

/usr/share/fonts/zh_CN/msyh.ttc: Microsoft YaHei,微软雅黑:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta

/usr/share/fonts/zh_CN/msjhl.ttc: Microsoft JhengHei UI,Microsoft JhengHei UI Light:style=Light,Regular

/usr/share/fonts/zh_CN/simsun.ttc: NSimSun,新宋体:style=Regular,常规

/usr/share/fonts/zh_CN/STLITI.TTF: STLiti,华文隶书:style=Regular

/usr/share/fonts/zh_CN/STZHONGS.TTF: STZhongsong,华文中宋:style=Regular

/usr/share/fonts/zh_CN/STKAITI.TTF: STKaiti,华文楷体:style=Regular

/usr/share/fonts/zh_CN/msjhbd.ttc: Microsoft JhengHei,微軟正黑體:style=Negreta,Bold,tučné,fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,Lodia

/usr/share/fonts/zh_CN/msjh.ttc: Microsoft JhengHei UI:style=Normal,Regular,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta

/usr/share/fonts/zh_CN/msyhbd.ttc: Microsoft YaHei,微软雅黑:style=Bold,Negreta,tučné,fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,Lodia

/usr/share/fonts/zh_CN/msyhl.ttc: Microsoft YaHei,微软雅黑,Microsoft YaHei Light,微软雅黑 Light:style=Light,Regular

/usr/share/fonts/zh_CN/msjhbd.ttc: Microsoft JhengHei UI:style=Negreta,Bold,tučné,fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,Lodia

/usr/share/fonts/zh_CN/STXIHEI.TTF: STXihei,华文细黑:style=Regular

/usr/share/fonts/zh_CN/STCAIYUN.TTF: STCaiyun,华文彩云:style=Regular

/usr/share/fonts/zh_CN/SIMYOU.TTF: YouYuan,幼圆:style=Regular

/usr/share/fonts/zh_CN/simfang.ttf: FangSong,仿宋:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta

/usr/share/fonts/zh_CN/msyhbd.ttc: Microsoft YaHei UI:style=Bold,Negreta,tučné,fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,Lodia

linux添加中文字库主线任务,Linux 添加中文字体库相关推荐

  1. CentOS Linux安装中文字体库,解决中文乱码问题

    CentOS Linux安装中文字体库,解决中文乱码问题 原因 解决步骤 fc-list 原因 CentOS中没有安装中文字体库,会出现中文乱码问题,解决问题需安装中文字库 解决步骤 Centos7系 ...

  2. java 中文字体_Linux 添加中文字体库,解决Java 生成中文水印不显示问题

    本机 Windows 环境测试以下代码生成中文水印完全没问题,但是发布到Linux下不显示,一开始以为是报错了没打印出来,搜索发现直接提示中文乱码的或者不显示的,才明白原来是字体库原因,于是开始解决这 ...

  3. centos 安装中文字体库

    1.创建中文字体库目录 cd /usr/share/fonts mkdir chinese 2.添加中文字体库到该中目录 # Windows中存在部分字体库可直接复制到/usr/share/fonts ...

  4. TextMeshPro创建中文字体库

    前提:使用的source字体库里面必须包含有你所需要的字 创建: Window => TextMeshPro => Font Asset Creator 基本的设置就不说了,主要需要设置的 ...

  5. 树莓派系统汉化教程(汉语+中文字体库+中文输入法pinyin(拼音))

    目录 一.语言和区域设置 1.在putty登录树莓派,在命令行输入sudo nano raspi-config,然后回车如下图: 2.选择 5 Localisation Options Configu ...

  6. Linux无root权限解决matplotlib中文字体各种疑难杂症

    问题简述 python经典中文字体问题,非管理员.无root环境下 matplotlib:seaborn 设置中文. 在使用yolov5训练的时候,报Warming Plotting labels t ...

  7. linux如何安装中文字体库

    Linux字体文件放在/usr/share/font/,只要将字体文件拷贝到这里就可以了. 这里示例安装Windows的所有字体. 1,新建路径存放字体库:/usr/share/fonts/ 2,进入 ...

  8. linux ctex缺少字体,解决ctex包在linux下找不到一些中文字体的问题

    ctex是LaTeX的ctex发行包提供的一个中文友好的宏包,同时提供文档类,提交到CTAN,一般的发行版都有,很好用.但是在archlinux下texlive使用时,xelatex编译提示找不到Si ...

  9. Linux中Debian版中安装中文字体

    转载于https://my.oschina.net/winHerson/blog/176990 本人查找了很多方法后,最后觉得好用的还是链接的这一版,以下内容是根据链接内容的基础加入的许多细节步骤. ...

最新文章

  1. Xcode快捷键及代码块
  2. asp.net 检测是否关注公众号_太阳电池缺陷检测方法光致发光检测法
  3. Adversarial Discriminative Domain Adaption 阅读笔记
  4. 用户,群组和权限 二
  5. java 进程运行时间_将Java类作为子进程运行
  6. 接口安全--签名验证
  7. matlab光学谐振腔稳区图,基于图像处理的光学谐振腔自准直研究方法
  8. 如何让地面不起灰_什么是不发火地面,如何施工?
  9. ln命令:软链接建立与删除
  10. 【图像处理基础】基于matlab图像Harris角点检测【含Matlab源码 1731期】
  11. 计算机网络之网络安全基础
  12. pip 下载安装时使用清华大学镜像(各种国内源配置)
  13. 运用windows shell修复Wannacry漏洞
  14. Python-OpenCV 图像加权混合(滤色, 叠加, 柔光, 强光)
  15. 自动化办公——PPT免费模板(强力推荐)
  16. PHP 7系列版本(7.0、7.1、7.2、7.3、7.4)新特性
  17. DNS缓存中毒攻击与防护
  18. application.yml与bootstrap.yml的区别
  19. 【图】上海居住证办理指南
  20. C++ 取json中的某一个值,解析json字符串

热门文章

  1. Ubuntu 运行Asp.net MVC3
  2. linux中DIR、dirent、opendir()、readdir()、closedir()函数的使用
  3. memcmp()库函数实现
  4. 单例模式(Java)
  5. C语言 数据结构 树和二叉树
  6. Linux 设备驱动模型中的class(类)
  7. Cs代码写在html页面哪里,当用于在details.cshtml页面上查看时,我用什么代码来查看模型中的项目列表?...
  8. 能运行shell吗_terminal, shell, bash, zsh
  9. 将DataFrame格式的数据存入到mysql数据库中
  10. form.html,HTML表单form