I'm using PhantomJS 2.1.1 on CentOS with the example script rasterize.js
just to reproduce the screenshot problem, which is to take a screenshot of a simple web-font demo site:
http://castellsonclaret.com/public/external/georgiapro/demo.htm
It should render like so (as taken using the SaaS PhantomJSCloud service):
However, with PhantomJS 2.1.1 locally I get
First I increased the script timeout to 10s just to be sure that isn't the issue.
Next I thought the css or fonts were blocked somehow from downloading. When I use tcpflow
(it's like wireshark) before running phantomjs
scripts I can see that the above web page is downloading the .woff
fonts. However, they are not being rendered in the screenshot I'm taking.
When I run the following before the phantomjs script
tcpflow -p -c -i eth0 port 80 | grep -oE '(GET|POST|HEAD) .* HTTP/1.[01]'
I can see the fonts are being downloaded. Real console output:
GET /public/external/georgiapro/demo.htm HTTP/1.1
GET /t/1.css?apiType=css&projectid=4a82c0c9-a48a-4ef5-97ae-de0d7e62c8d0 HTTP/1.1
GET /public/external/georgiapro/Fonts/a5d15255-f5b4-4cca-808f-211ec0f25ac8.woff HTTP/1.1
GET /public/external/georgiapro/Fonts/3859825b-bdc4-47f3-af3d-a2ef42d58cfb.woff HTTP/1.1
... [snip] ...
GET /public/external/georgiapro/Fonts/ab79a7ac-4aaf-4393-896b-feb6610c9528.woff HTTP/1.1
I then thought that PhantomJS 2.x still doesn't support woff, but 1) it is supposed to be supported (see here), and 2) the SaaS PhantomJSCloud service can render them fine. Is there something more that is needed to be done to render web fonts?
Update: I've confirmed zlib is installed, and compiled PhantomJS 2.1.1 from source, but the results are still the same as above.
Update: Chrome has headless support, and that is the reason why on April 13 the maintainer of PhrantomJS has announced he is stepping down. Eventually we will switch to headless Chrome. Can headless Chrome handle web fonts?