renathy
renathy

Reputation: 5355

How to load Georgia font to Dompdf

I do not understand how to change font in Dompdf.

I have the following stylesheet: font-family: Georgia,Serif, "Times New Roman"; I need Georgia font on the PDF.

I have found Gerogia fonts in Dompdf website and put them into /dompdf/lib/fonts folder (there are Georgia.afm, Georgia_Bold.afm, Georgia_Bold_Italic.afm, Georgia_Italic.afm files). But ti seems that those files never loads.

Give me, please, some clues how to use include files and use Gerogia font.

Upvotes: 1

Views: 2572

Answers (2)

BrianS
BrianS

Reputation: 13914

In dompdf v0.5.x the font metrics for Georgia, Verdana, and a few other fonts were mistakenly included in the download. These .AFM files are the metrics for the fonts not the fonts themselves (which end in .TTF).

In order to use a font other than the core fonts (Helvetica, Times, Courier, Symbol, and ZapfDingbats) you have to load the font into dompdf. As described by @shankar-damodaran you do this using the load_font.php script.

In dompdf 0.6.0 the DejaVu fonts were included. These provide for a larger character representation than what you get with the core fonts. And you don't have to load the font since it is already included. Also in v0.6.0 is a new web-based font loader located at dompdf/www/fonts.php.

If you're going to load fonts for use with dompdf you should upgrade to v0.6.0. It's much improved in some ways over the previous version. Not the least of which is a PHP-based font handling library making it much easier to load fonts then with v0.5.1.

Lastly, you CSS is a little off. You should start with the most specific font and work your way to the least specific. So it should be:

font-family: Georgia, "Times New Roman", Serif;

Upvotes: 1

You need to load the font from the command line interface. Something like this

php load_font.php FontName /font.ttf

enter image description here

Source

Upvotes: 0

Related Questions