phantomjs屏幕截图字体丢失,改为显示框 [英] phantomjs screenshot font missing, boxes rendered instead

查看:356
本文介绍了phantomjs屏幕截图字体丢失,改为显示框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Centos 6.3上使用PhantomJs 1.8.1进行自动化ui测试.如果测试失败,则屏幕截图将保存到文件系统中.

I am using PhantomJs 1.8.1 on Centos 6.3 to for automated ui tests. When a test fails, screenshots are saved to the file system.

我的问题是,即使屏幕截图已保存,它们也不包含可读字体.

My problem is that even though the screenshots are saved, they do not contain readable fonts.

因此,如果网站显示如下:

So if the website reads like this:

你好,世界!

该网站的屏幕截图如下所示:

the screenshot of the site will look like this:

因此,它渲染并保存了小盒子,而不是实际的字母.

So, instead of the actual letters, it renders and saves little boxes.

系统为centos 6.3. Freetype和Fontconfig也已安装.

The system is centos 6.3. Freetype and Fontconfig are also installed.

我该如何解决这个问题?

How could i go about fixing this?

谢谢!

推荐答案

我对日语字体有类似的问题. (PhantomJS 1.9.1,Amazon EC2上的Redhat)

I had a similar problem with Japanese fonts. (PhantomJS 1.9.1, Redhat on Amazon EC2)

英语字符显示很好,但是日语字符显示为方框.

English characters showed up fine, but Japanese characters were rendered as boxes.

1)使用yum install安装(日语)IPA字体(Mincho和Gothic).

1) Installed the (Japanese) IPA fonts (Mincho and Gothic) using yum install.

(使用yum list检查确切的软件包名称.)

(Use yum list to check the exact package names.)

2)IPA .ttf文件已安装到:

2) The IPA .ttf files were installed to:

  • /usr/share/fonts/IPA-Gothic/
  • /usr/share/fonts/IPA-Mincho/
  • /usr/share/fonts/IPA-Gothic/
  • /usr/share/fonts/IPA-Mincho/

3)将两个下载的.ttf文件移动到此目录:(创建)

3) Move the two downloaded .ttf files to this directory: (Create it)

  • /usr/share/fonts/ipa/

4)备份/etc/fonts/fonts.conf

5)编辑原始的/etc/fonts/fonts.conf并填充以下内容:

5) Edit the original /etc/fonts/fonts.conf and fill it with this:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <dir>/usr/share/fonts/ipa</dir>
  <cachedir>/var/cache/fontconfig</cachedir>
  <cachedir>~/.fontconfig</cachedir>
  <alias>
    <family>serif</family>
    <prefer>
      <family>IPAP Mincho</family>
    </prefer>
  </alias>
  <alias>
    <family>sans serif</family>
    <prefer>
      <family>IPAP Gothic</family>
    </prefer>
  </alias>
  <alias>
    <family>monospace</family>
    <prefer>
      <family>IPA Gothic</family>
    </prefer>
  </alias>
</fontconfig>

6)用fc-cache -vf

7)享受您的新工作字体.

7) Enjoy your new working fonts.

  • 如果没有字符(空格),则字体缓存可能已过期. 尝试fc-cache -vf重新生成它.

  • If you're getting no characters (blank space), your font cache is probably out of date. Try fc-cache -vf to regenerate it.

1.9.1版本中有一个针对日文/中文/韩文字符的修复程序.不确定是否会有所作为,但可能值得从1.9.0升级.

There's a fix for Japanese/Chinese/Korean characters in the 1.9.1 release. Not sure if it makes a difference, but probably worth upgrading from 1.9.0.

这篇关于phantomjs屏幕截图字体丢失,改为显示框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆