Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including custom fonts in .fonts folder in heroku, seems not recognizing them

Heroku support told me that in order to use custom fonts in my web app (not installed in the system, you can see the installed ones with fc-list in a bash console) I had to deploy a .fonts folder with all the fonts inside.

The problem is that I don't know how to do it. I mean, I don't know if the name of the file has to follow any special pattern for heroku or I must do something in my code to consider this fonts or it's something automatic if I include it in the folder...

The fact is that I tried changing the filename of the font in different ways and the font is not used at all.

To give you more details, the process were we're using the font is to convert a PDF to an image, more concretely, with the rghost gem. And the final image doesn't use the custom font at all.

Thanks in advance, any idea is welcome.

like image 914
josal Avatar asked May 16 '13 16:05

josal


1 Answers

I would just create a fonts/ directory in the root folder of the project and then load the fonts like this, for example in config/initializers/rghost.rb:

RGhost::Config::GS[:extensions] << "#{Rails.root}/fonts/LTSyntax.ttf"

The documentation states that you will also need a Fontmap file in the fonts directory, for example:

/Syntax (LTSyntax.ttf); 

Your problem is that the PDF references fonts that are not embedded into the PDF. You can obtain a list of fonts that are used in the PDF with xpdf, using the pdffonts command:

> pdffonts example.pdf
name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
Syntax                               Type 1            no  no  no       8  0

Alternatively, you can also use this script from pdf-reader.

like image 69
Patrick Oscity Avatar answered Oct 04 '22 11:10

Patrick Oscity