Linux下文档类型转PDF乱码解决方式
在 Linux 系统下进行文本类型转 PDF 时出现乱码。
解决方案:
安装 fontconfig
安装命令:
yum –y install fontconfig
在/usr/share/fonts 目录下新建一个目录 chinese
操作命令:
cd /usr/share/fonts
mkdir chinese
cd chinese
修改文件夹权限
操作命令:
chmod -R 755 /usr/share/fonts/chinese/
将本地字体上传至服务器
操作步骤:
- 将 C:\Windows\Fonts 目录下的字体拷贝到一个新建文件夹(因为文件夹权限无法直接上传,所以需要创建一个新建文件夹)
- 将需要的字体上传到服务器的/usr/share/fonts/chinese 目录下
安装 ttmkfdir
安装命令:
yum -y install ttmkfdir
ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir
修改 fonts.conf 配置文件
操作命令:
vi /etc/fonts/fonts.conf
<!-- Font directory list -->
<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 prefix="xdg">fonts</dir>
<dir>/usr/share/fonts/chinese</dir> #这里是你要添加的路径
<!-- the following element will be removed in the future -->
<dir>~/.fonts</dir>刷新 Liunx 字体缓存
操作命令:
mkfontdir
mkfontscale
fc-cache –fv
fc-list :lang=ZH
重启服务器(完成配置)(注意:第 7 步完成之后如果生效了。那么就不用之行第 8 步了)
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment