phantomjs screenshot font missing, boxes rendered

2019-01-13 07:37发布

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:

Hello, World!

the screenshot of the site will look like this:

enter image description here

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

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

How could i go about fixing this?

Thx!

标签: phantomjs
10条回答
够拽才男人
2楼-- · 2019-01-13 08:23

leave the /etc/fonts/fonts.conf file alone. the example above is making only Japanese work

yum install -y ipa-gothic-fonts.noarch ipa-mincho-fonts.noarch cjkuni-ukai-fonts.noarch bitmap-fonts bitmap-fonts-cjk urw-fonts fontconfig freetype*

yum groupinstall -y 'Korean Support' 'Chinese Support' 'Japanese Support' 'Kannada Support' 'Hindi Support' 'Arabic Support'

fc-cache -vf

查看更多
叛逆
3楼-- · 2019-01-13 08:24

I had the same problem.

Installing the urw-fonts package solved it for me:

yum install urw-fonts

查看更多
Fickle 薄情
4楼-- · 2019-01-13 08:25

For Chinese font, I had it solved by the following steps:

sudo apt-get install language-pack-zh-hans
sudo apt-get install ttf-arphic-uming
sudo apt-get install ttf-dejavu ttf-wqy-microhei
sudo fc-cache -f -v

OS is Ubuntu 12.04 LTS

查看更多
我命由我不由天
5楼-- · 2019-01-13 08:29

I faced same issue with Arabic fonts. This is what i did.

yum groupinstall 'Arabic Support'.

Installing Arabic Support solved it for me.

查看更多
叼着烟拽天下
6楼-- · 2019-01-13 08:31

Try this for Chinese.

yum install bitmap-fonts bitmap-fonts-cjk
查看更多
时光不老,我们不散
7楼-- · 2019-01-13 08:34

You can run the script with command line parameters:

phanthomjs --output-encoding=cp866 [params] [filename]
查看更多
登录 后发表回答