Pregunta

I'm trying to make phantom.js work on heroku, so far I've managed to launch a custom buildpack and run the binary file.

However, it seems that in order to render things correctly I need to also install Freetype and Fontconfig. Heroku doesn't seem to have them and I was wondering if this is something feasible or if I need to scrap this option and find another solution.

Does anyone know how to do this? Thank you.

¿Fue útil?

Solución

Maybe you can simply use the phantomjs buildpack proposed from a third party. You can find here : https://devcenter.heroku.com/articles/third-party-buildpacks some third party buildpack. And one of them is phantomjs. This buildpack already includes Freetype and Fontconfig!

Otros consejos

A different approach, which may work for you, is to install the fonts necessary as system fonts on the dyno that your app runs on.

In short: Make relevant symlinks from each font file into ~/.fonts/ upon application start.

Then, collect the TTFs you need in, say, your applications's vendor/fonts folder, version-controlled and neat.

If you were to use Ruby on Rails, you may do exactly like the following, but it's probably very doable in your Node.js environment, too.

This Rails-oriented blog post details the thing but here is the relevant code as an initializer, that you could call config/initializers/system_fonts.rb:

if Rails.env.production?
  font_dir = File.join(Dir.home, ".fonts")
  Dir.mkdir(font_dir) unless Dir.exists?(font_dir)

  Dir.glob(Rails.root.join("vendor", "fonts", "*")).each do |font|
    target = File.join(font_dir, File.basename(font))
    File.symlink(font, target) unless File.exists?(target)
  end
end

Heroku doesn't support "installing" binaries on a per app basis. Instead, it follows the twelve-factor tenet of dependency isolation which recommends that all dependencies are packages with the application. So, you would include the Freetype and Fontconfig bins in your application structure and adjust the PATH to include this dir.

According to https://devcenter.heroku.com/articles/cedar-ubuntu-packages fontconfig should be available (now) on both Cedar-10- and Cedar-14-stack.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top