linux添加中文字库主线任务,Linux 添加中文字体库
背景:潤乾報表 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 添加中文字体库的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 鸿蒙系统怎么换windows,求助~鸿蒙
- 下一篇: Linux Ubuntu 安装 anac