Posted the patch for php 5.3.0 on the project's page PHP/GD: Better Freetype2.
Also fixed another bug causing segmentation faults when using imagettftext() instead of imagefttext().
Posted the patch for php 5.3.0 on the project's page PHP/GD: Better Freetype2.
Also fixed another bug causing segmentation faults when using imagettftext() instead of imagefttext().
The patch giving more control over Freetype2’s parameters in PHP/GD has been updated!
The nasty bug that made the optional parameter $extrainfo not really optional (omitting it caused no font output) was fixed at last (a minor fix, but laziness is hard to overcome sometimes).
Also released new patches for PHP 5.2.8 and 5.2.9.
See project PHP/GD: Better Freetype2.
So you want to render a nice PostScript Type 1 font (.pfb/.pfa) using PHP+GD. Sadly, you just realized you can’t load the associated font metrics (.pfm/.afm) in PHP.
The “afm” (ASCII) and “pfm” (Binary) metric files contain, amongst other things, the metrics and the kerning information about the font. To render a font correctly, both the font and the metrics are required.
Freetype2 supports metrics, but you have to load them up “manually”, using the FT_Attach_Stream() or FT_Attach_File() functions. Sadly GD (and PHP) knows nothing about PostScript metric files.
Years ago, I made a patch to PHP’s GD module, allowing me to use most of Freetype2’s rendering options.
When I first made this patch (somewhere in the PHP3 years), the extension always forced autohints, even when compiling freetype2 with bytecode support. Later on, they changed this to a better default, but you still couldn't render a font, for example, without anti-aliasing.
Today, I cleaned up my patch a bit and released it on its project page. Maybe someday I'll clean it up for real and submit it for inclusion in PHP, but I'm not there yet :P
Anyway, have fun with fonts.. or not :)
© Serge Émond
Proudly powered by django, Sphinx & Arch Linux