linux系统安装中文字体
以人事系统中,kkfileview 文件预览服务为例,进行容器内中文字体安装
人事系统中,缺失中文字体,以下为安装过程。(如果容器被删除,则每次都要执行以下内容)
1.下载字体
142人事系统已经下载好,字体放在目录 mycn
下
[runpu@localhost kkfileview]$ pwd
/home/runpu/services/services/kkfileview
[runpu@localhost kkfileview]$ ls
mycn
[runpu@localhost kkfileview]$ ll mycn/
total 49584
-rw-rw-r-- 1 runpu runpu 409280 Aug 5 17:39 times.ttf
-rw-rw-r-- 1 runpu runpu 3996872 Aug 5 17:39 仿宋_GB2312.ttf
-rw-rw-r-- 1 runpu runpu 15323200 Aug 5 17:39 新宋体.ttc
-rw-rw-r-- 1 runpu runpu 13099364 Aug 5 17:39 方正小标宋_GBK.TTF
-rw-rw-r-- 1 runpu runpu 4045592 Aug 5 17:39 方正小标宋简体.ttf
-rw-rw-r-- 1 runpu runpu 4135804 Aug 5 17:39 楷体_GB2312.ttf
-rw-rw-r-- 1 runpu runpu 9751960 Aug 5 17:39 黑体.ttf
2.将字体拷贝到 kkfileview 容器中
将字体拷贝到容器中 /usr/share/fonts
目录下
[runpu@localhost kkfileview]$ docker cp mycn kkfileview:/usr/share/fonts/
3.进入容器内,更新字体缓存
进入容器内,查看 usr/share/fonts
目录下刚刚拷贝的字体
[runpu@localhost kkfileview]$ docker exec -it kkfileview bash
root@localhost:/# cd /usr/share/fonts/
root@localhost:/usr/share/fonts# ls
chinese mycn truetype X11
root@localhost:/usr/share/fonts# ll mycn/
总用量 49588
drwxr-xr-x 2 1001 1001 189 8月 5 17:46 ./
drwxr-xr-x. 1 root root 18 8月 6 11:28 ../
-rw-rw-r-- 1 1001 1001 4045592 8月 5 17:39 方正小标宋简体.ttf
-rw-rw-r-- 1 1001 1001 13099364 8月 5 17:39 方正小标宋_GBK.TTF
-rw-rw-r-- 1 1001 1001 3996872 8月 5 17:39 仿宋_GB2312.ttf
-rw-rw-r-- 1 1001 1001 9751960 8月 5 17:39 黑体.ttf
-rw-rw-r-- 1 1001 1001 4135804 8月 5 17:39 楷体_GB2312.ttf
-rw-rw-r-- 1 1001 1001 15323200 8月 5 17:39 新宋体.ttc
-rw-rw-r-- 1 1001 1001 409280 8月 5 17:39 times.ttf
-rw-r--r-- 1 1001 1001 36 8月 5 17:47 .uuid
更新缓存,执行命令 fc-cache -f -v
root@localhost:/usr/share/fonts# fc-cache -f -v
/usr/share/fonts: 正在生成缓存,新增缓存内容:0 个字体,4 个目录
/usr/share/fonts/X11: 正在生成缓存,新增缓存内容:0 个字体,3 个目录
/usr/share/fonts/X11/encodings: 正在生成缓存,新增缓存内容:0 个字体,1 个目录
/usr/share/fonts/X11/encodings/large: 正在生成缓存,新增缓存内容:0 个字体,0 个目录
/usr/share/fonts/X11/misc: 正在生成缓存,新增缓存内容:5 个字体,0 个目录
/usr/share/fonts/X11/util: 正在生成缓存,新增缓存内容:0 个字体,0 个目录
/usr/share/fonts/chinese: 正在生成缓存,新增缓存内容:24 个字体,0 个目录
/usr/share/fonts/mycn: 正在生成缓存,新增缓存内容:8 个字体,0 个目录
/usr/share/fonts/truetype: 正在生成缓存,新增缓存内容:0 个字体,4 个目录
/usr/share/fonts/truetype/dejavu: 正在生成缓存,新增缓存内容:6 个字体,0 个目录
/usr/share/fonts/truetype/liberation: 正在生成缓存,新增缓存内容:16 个字体,0 个目录
/usr/share/fonts/truetype/msttcorefonts: 正在生成缓存,新增缓存内容:0 个字体,0 个目录
/usr/share/fonts/truetype/wqy: 正在生成缓存,新增缓存内容:5 个字体,0 个目录
/usr/local/share/fonts: 正在生成缓存,新增缓存内容:0 个字体,0 个目录
/root/.local/share/fonts: 跳过,无此目录
/root/.fonts: 跳过,无此目录
/usr/share/fonts/X11: 跳过,探测到循环目录
/usr/share/fonts/chinese: 跳过,探测到循环目录
/usr/share/fonts/mycn: 跳过,探测到循环目录
/usr/share/fonts/truetype: 跳过,探测到循环目录
/usr/share/fonts/X11/encodings: 跳过,探测到循环目录
/usr/share/fonts/X11/misc: 跳过,探测到循环目录
/usr/share/fonts/X11/util: 跳过,探测到循环目录
/usr/share/fonts/truetype/dejavu: 跳过,探测到循环目录
/usr/share/fonts/truetype/liberation: 跳过,探测到循环目录
/usr/share/fonts/truetype/msttcorefonts: 跳过,探测到循环目录
/usr/share/fonts/truetype/wqy: 跳过,探测到循环目录
/usr/share/fonts/X11/encodings/large: 跳过,探测到循环目录
/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: 缓存生成成功
查看安装的中文字体,执行命令 fc-list :lang=zh
或者使用 fc-list | grep "想要查看的字体名"
root@localhost:/usr/share/fonts# fc-list :lang=zh
/usr/share/fonts/chinese/SIMYOU.TTF: 幼圆,YouYuan:style=Regular
/usr/share/fonts/mycn/楷体_GB2312.ttf: 楷体_GB2312,KaiTi_GB2312:style=Regular
/usr/share/fonts/chinese/FZSTK.TTF: 方正舒体,FZShuTi:style=Regular
/usr/share/fonts/truetype/wqy/wqy-microhei.ttc: 文泉驿微米黑,文泉驛微米黑,WenQuanYi Micro Hei:style=Regular
/usr/share/fonts/X11/misc/wenquanyi_13px.pcf: WenQuanYi Bitmap Song:style=Regular
/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc: 文泉驿正黑,文泉驛正黑,WenQuanYi Zen Hei:style=Regular
/usr/share/fonts/X11/misc/wenquanyi_12pt.pcf: WenQuanYi Bitmap Song:style=Regular
/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc: 文泉驿点阵正黑,文泉驛點陣正黑,WenQuanYi Zen Hei Sharp:style=Regular
/usr/share/fonts/chinese/STZHONGS.TTF: 华文中宋,STZhongsong:style=Regular
/usr/share/fonts/mycn/方正小标宋简体.ttf: 方正小标宋简体,FZXiaoBiaoSong\-B05S:style=Regular
/usr/share/fonts/chinese/simkai.ttf: 楷体,KaiTi:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/mycn/新宋体.ttc: 宋体,SimSun:style=Regular
/usr/share/fonts/chinese/msyh.ttf: 微软雅黑,Microsoft YaHei:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/chinese/simsun.ttc: 新宋体,NSimSun:style=Regular
/usr/share/fonts/mycn/方正小标宋_GBK.TTF: 方正小标宋_GBK,FZXiaoBiaoSong\-B05:style=Regular
/usr/share/fonts/chinese/simhei.ttf: 黑体,SimHei:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/X11/misc/wenquanyi_10pt.pcf: WenQuanYi Bitmap Song:style=Regular
/usr/share/fonts/chinese/STCAIYUN.TTF: 华文彩云,STCaiyun:style=Regular
/usr/share/fonts/X11/misc/wenquanyi_9pt.pcf: WenQuanYi Bitmap Song:style=Regular
/usr/share/fonts/chinese/msyhl.ttc: 微软雅黑,Microsoft YaHei,Microsoft YaHei Light,微软雅黑 Light:style=Light,Regular
/usr/share/fonts/X11/misc/wenquanyi_11pt.pcf: WenQuanYi Bitmap Song:style=Regular
/usr/share/fonts/chinese/msyhbd.ttf: 微软雅黑,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/chinese/STHUPO.TTF: 华文琥珀,STHupo:style=Regular
/usr/share/fonts/chinese/msyhl.ttc: Microsoft YaHei UI,Microsoft YaHei UI Light:style=Light,Regular
/usr/share/fonts/chinese/simsun.ttc: 宋体,SimSun:style=Regular
/usr/share/fonts/chinese/STXINGKA.TTF: 华文行楷,STXingkai:style=Regular
/usr/share/fonts/chinese/STXINWEI.TTF: 华文新魏,STXinwei:style=Regular
/usr/share/fonts/chinese/STKAITI.TTF: 华文楷体,STKaiti:style=Regular
/usr/share/fonts/chinese/SIMLI.TTF: 隶书,LiSu:style=Regular
/usr/share/fonts/chinese/STSONG.TTF: 华文宋体,STSong:style=Regular
/usr/share/fonts/chinese/STXIHEI.TTF: 华文细黑,STXihei:style=Regular
/usr/share/fonts/chinese/STLITI.TTF: 华文隶书,STLiti:style=Regular
/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc: 文泉驿等宽正黑,文泉驛等寬正黑,WenQuanYi Zen Hei Mono:style=Regular
/usr/share/fonts/truetype/wqy/wqy-microhei.ttc: 文泉驿等宽微米黑,文泉驛等寬微米黑,WenQuanYi Micro Hei Mono:style=Regular
/usr/share/fonts/mycn/仿宋_GB2312.ttf: 仿宋_GB2312,FangSong_GB2312:style=Regular
/usr/share/fonts/mycn/黑体.ttf: 黑体,SimHei:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
/usr/share/fonts/chinese/STFANGSO.TTF: 华文仿宋,STFangsong:style=Regular
/usr/share/fonts/mycn/新宋体.ttc: 新宋体,NSimSun:style=Regular
/usr/share/fonts/chinese/FZYTK.TTF: 方正姚体,FZYaoTi:style=Regular
/usr/share/fonts/chinese/simfang.ttf: 仿宋,FangSong:style=Regular,Normal,obyčejné,Standard,Κανονικά,Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
或者过滤想要查看的字体:
root@localhost:/usr/share/fonts# fc-list | grep "方正小标宋简体.ttf"
/usr/share/fonts/mycn/方正小标宋简体.ttf: 方正小标宋简体,FZXiaoBiaoSong\-B05S:style=Regular
4.删除旧文件生成的pdf
线上已经执行过该操作了,直接跳到下一步即可。
该步骤是针对之前已经成的pdf,但展示有问题的,删除掉就行,平台查看的时候会重新生成。
root@localhost:/usr/share/fonts# cd /opt/kkFileView-4.1.0/file/
root@localhost:/opt/kkFileView-4.1.0/file# ls
01321802-3c61-4c27-939a-a484c56be5e7.docx 82f27729-0549-45b7-af20-8fe67e9fd3e9.docx a89b5fe6-2928-483f-9bb3-b073634660c0.doc
01321802-3c61-4c27-939a-a484c56be5e7.pdf 82f27729-0549-45b7-af20-8fe67e9fd3e9.pdf a89b5fe6-2928-483f-9bb3-b073634660c0.pdf
root@localhost:/opt/kkFileView-4.1.0/file# rm -f ./*.pdf
root@localhost:/opt/kkFileView-4.1.0/file# ls
01321802-3c61-4c27-939a-a484c56be5e7.docx 82f27729-0549-45b7-af20-8fe67e9fd3e9.docx a89b5fe6-2928-483f-9bb3-b073634660c0.doc
5.退出并重启容器
root@localhost:/opt/kkFileView-4.1.0/file# exit
exit
[runpu@localhost kkfileview]$ cd /home/runpu/services
[runpu@localhost services]$ docker-compose restart fileviewer
作者:hbrunpu 创建时间:2024-08-06 14:06
最后编辑:hbrunpu 更新时间:2024-08-06 14:08
最后编辑:hbrunpu 更新时间:2024-08-06 14:08