缘由:测试环境和生产环境系统字符集都是LANG=en_US.utf8,程序在测试环境通过下述方式生成的图片里面的中文可以正常显示,生产环境不行,排查原因为生产环境确认对应的字体,采取后续方法增加字体。
1、C:\Windows\Fonts下找到字体文件simsun.ttc,重命名为simsun.ttf; 2、上传到主机/usr/share/fonts/zh_CN/ 3、修改文件权限755 4、mkfontscale (如果提示 mkfontscale: command not found,需自行安装 # yum install mkfontscale ) 5、mkfontdir 6、fc-cache -fv (如果提示 fc-cache: command not found,则需要安装# yum install fontconfig ) 或 fc-cache /usr/share/fonts/zh_CN/ 7、reboot系统(生产环境,未做此操作,执行完fc-cache /usr/share/fonts/zh_CN/后fc-list验证新字体已存在,应用乱码问题经验证也已解决,说明reboot不是必须。)
验证字体: fc-list|grep 宋
fc-list :lang=zh-cn | sort
参考: https://www.cnblogs.com/maybo/p/5182492.html https://blog.csdn.net/atpalain_csdn/article/details/50801639 http://xuguiyi1000.iteye.com/blog/1258499 --------------------- 作者:川中胡子 来源: 原文:https://blog.csdn.net/qq_40809549/article/details/80523849 版权声明:本文为博主原创文章,转载请附上博文链接!