Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhantomJS screenshots not showing text

I'm using PhantomJS to run some automated tests through Codeception. When I generate a screenshot however the page shows but none of the text does, like the sample below.

enter image description here

Here is the script I use to install phantomjs. I'm using CentOS 7.1

echo "## Install phantomjs dependencies"
sudo yum install freetype-devel fontconfig-devel libicu-devel gcc glib libpng-devel bison sqlite-devel gperf flex libjpeg-devel  -y

echo "## Install phantomjs"
cd ~
PHANTOM_JS="phantomjs-2.1.1-linux-x86_64"
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
sudo mv $PHANTOM_JS.tar.bz2 /usr/local/share/
cd /usr/local/share/
sudo tar xvjf $PHANTOM_JS.tar.bz2
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/share/phantomjs
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin/phantomjs
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/bin/phantomjs
sudo rm -fr $PHANTOM_JS.tar.bz2
phantomjs -v

My initial thought was I'm missing a font library but from what I can read on the phantomjs site I should have all the packages.

like image 817
Paul Sheldrake Avatar asked Apr 01 '16 21:04

Paul Sheldrake


1 Answers

So it looks like my version of CentOS does not actually have any fonts installed. Adding the following lines to my PhantomJS install script added some fonts to the system and the screenshots worked as expected.

sudo yum install cabextract xorg-x11-font-utils -y
sudo rpm -i https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.6-1.noarch.rpm
like image 163
Paul Sheldrake Avatar answered Sep 30 '22 03:09

Paul Sheldrake