confluence上传中文附件时,显示乱码。因为linux系统没有中文字体支持,导致无法显示中文。
1. 安装新字体库
linux用fontconfig来安装字体库
# yum -y install fontconfig #一般是默认自带的
安装成功后,在/usr/shared目录就可以看到fonts和fontconfig目录
创建字体目录
# mkdir -p /usr/share/fonts/windowsfonts
并将windows中C:\Windows\Fonts\ 所有字体拖拽到这个目录下,也可以选择需要的字体
修改windowsfonts目录的权限
# chmod -R 755 /usr/share/fonts/windowsfonts/
安装ttmkfdir来搜索目录中所有的字体信息,并汇总生成fonts.scale文件
# yum -y install ttmkfdir #一般会默认自带
执行ttmkfdir命令
# cd /usr/share/fonts/windowsfonts/
# mkdir -p /usr/share/X11/fonts/encodings/encodings.dir
# ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir
会在/usr/share/fontconfig/windowsfonts/目录下生成fonts.scale文件
修改字体配置文件
# vi /etc/fonts/fonts.conf
<dir>/usr/share/fonts</dir>
<dir>/usr/share/X11/fonts/Type1</dir> <dir>/usr/share/X11/fonts/TTF</dir> <dir>/usr/local/share/fonts</dir>
<dir>/usr/share/fonts/windowsfonts</dir> #添加这一行
<dir prefix="xdg">fonts</dir>
<!-- the following element will be removed in the future -->
<dir>~/.fonts</dir>
刷新内存中的字体缓存
# fc-cache
通过fc-list看一下字体列表
# fc-list
至此,已经成功安装上了中文字体
2. 修改setenv.sh找到CATALINA_OPTS并添加一行
# vi /data/confluence/bin/setenv.sh
添加一行
CATALINA_OPTS="-Dconfluence.document.conversion.fontpath=/usr/share/fonts/windowsfonts/ ${CATALINA_OPTS}"
3.备份并清空缓存目录
不清空的话, confluence预览旧文件时还是会显示方框,只有新文件才会正常
# cd /data/confluence-home/shared-home
备份清空dcl-document、dcl-thumbnail和dcl-document_hd目录
4. 重启confluence
# /data/confluence/bin/shutdown.sh
# su - confluence -s /bin/sh -c /data/confluence/bin/start-confluence.sh
参考:https://confluence.atlassian.com/confkb/the-text-in-a-powerpoint-excel-or-word-document-looks-different-when-using-the-viewfile-macro-200213562.html