0

I'm trying to use cutycapt to take iPhone-sized screenshots of sites, to test a mobile app, rather than having to go and manually take screenshots every time the CSS changes.

The problem I'm running into is that cutycapt isn't rendering or loading custom web fonts, either served from a fonts directory, or by Google Web Fonts.

Example screenshot - Google Web Fonts.

I'm running cutycapt using xvfb-run on a Ubuntu server. The command I'm using is something like this:

xvfb-run --server-args="-screen 0, 1024x768x24" \
cutycapt --url={url} --out=/tmp/test2.png \
--min-width=640 --min-height=960 \ 
--user-agent="Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7" \
--delay=2000 --header=X_SCREEN_DIMENSIONS:640x960
Andrew Stewart
  • 710
  • 1
  • 6
  • 10

2 Answers2

3

I'm using xvfb-run for wkhtmltoimage and had the same issue of custom fonts not rendering in the image output.

To solve the issue, I installed the custom font on my server following the instructions here: http://www.cangjie.info/public/howto/ubuntu_fonts/ubuntu_fonts.php

I downloaded the ttf file from google web fonts and placed it in:

/usr/share/fonts/truetype/custom/customfont.ttf

After placing the font, I refreshed the font cache: sudo fc-cache -fv

If you get a 'command not found' error trying to refresh the font cache, install fontconfig:

apt-get install fontconfig
ch1pn3ss
  • 429
  • 3
  • 10
0

I use this to resolve this same problem. But it will take some time to download all of the fonts.:

sudo apt-get install ttf-wqy-zenhei
sudo apt-get install xfs xfonts* -y 
Rob
  • 26,989
  • 16
  • 82
  • 98
Chen
  • 66
  • 3