Search code examples
fontsrenderingscreenshotphantomjspoltergeist

Capybara with Poltergeist (PhantomJS) not rendering page and fonts correctly


The setup in spec_helper.rb is:

require 'capybara/poltergeist'

Capybara.register_driver :poltergeist do |app|
  Capybara::Poltergeist::Driver.new(app, { js_errors: true }) 
end

Capybara.javascript_driver = :poltergeist

Then in the scenario I have:

save_screenshot('tmp/screenshot.png', :full => true)

One more thing. The fonts aren't good. I'm using Google font, but it's not rendered correctly only in Poltergeist.

%link{href: "http://fonts.googleapis.com/css?family=Open+Sans:400,300", rel: "stylesheet", type: "text/css"}

As a result, whole page looks broken. Am I missing some configuration?


Solution

  • For anyone interested, there's no support for Google fonts right now. Google fonts are in .woff format. You need to download the desired font, and then it should work.

    More info.