View Full Version : imagettftext kerning issue

01-09-2010, 03:55 AM
I'm creating some text using imagettftext (http://us2.php.net/manual/en/function.imagettftext.php). All works well with some TTF fonts on my local XAMPP server (running on Windows OS), although I had to adjust the kerning of characters manually by iterating through each character of my string and incrementally increasing the x coordinate (using the text bounding box values returned by imagettftext).

Anyway, it worked fine. Then I moved the code and TTF fonts over to my Linux production server, and the text looks like crap. It appears as if all the work I did to manually insert spacing between characters is negated, and the kerning looks messed up again -- the letters are all scrunched together.

My best guess is that this is either a PHP/GD/FreeType configuration issue or an OS issue (fonts rendering differently on Linux versus MS Windows). Either way, I can't figure out a way to fix the kerning problem on the production server.

I've Googled endlessly for an answer and come up with very little: Found this bug report: http://bugs.php.net/bug.php?id=30652. It doesn't mention kerning, but it suggests fonts are rendered differently on different OS's?

For the record, I'm running PHP v.5.2.11, GD v.2.0.34, and FreeType v.2.2.1. The production server is a commercial web hosting company.

Note: I'm wondering if there is any way to edit the FreeType configuration (as per the linked bug report) on a shared server? Sort of like using one's own php.ini to override the server's PHP configuration...

Any help is appreciated here...I'm completely stuck...:(