zoukankan      html  css  js  c++  java
  • puppeteer使用截图功能出现乱码

    一般的linux机器是没有中文字库的,解决方案就是对linux机器安装中文字库

    一、安装fontconfig

    yum -y install fontconfig

    这个命令执行完成之后,就可以在/usr/share文件夹里面看到fonts和fontconfig

    二、添加中文字体库
    从window的C:WindowsFonts里面把你需要的字体拷贝出来。比如simfang.ttf
    在CentOS的/usr/share/fonts新建一个叫chinese的文件夹
    然后把刚刚拷贝字体放到CentOS的/usr/share/fonts/chinese里面
    修改chinese目录的权限:
     chmod -R 775 /usr/share/fonts/chinese

    接下来需要安装ttmkfdir来搜索目录中所有的字体信息,并汇总生成fonts.scale文件,输入命令

     yum -y install ttmkfdir
     ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir
    

    修改字体配置文件 

    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>/usr/local/share/fonts/chinese</dir>
     <dir prefix="xdg">fonts</dir>
     <!-- the following element will be removed in the future -->
     <dir>~/.fonts</dir>
    
    刷新内存中的字体缓存,fc-cache
    
    看一下现在机器上已经有了刚才添加的字体。fc-list :lang=zh

    现在再运行一下截图,就没问题啦~

  • 相关阅读:
    求1977!
    三进制小数
    回文数C语言
    JAVA知识点必看
    servlet HttpServletRequest
    为什么web工程要输入localhost或者是127.0.0.1
    service $sce or ng-bind-html
    jQuery的deferred对象详解
    理解promise
    理解Angular中的$apply()以及$digest()
  • 原文地址:https://www.cnblogs.com/xzlive/p/14844026.html
Copyright © 2011-2022 走看看