Knowing this problem has been adressed before at PHP update kerning problem with imagettftext() and imagefttext() functions but witout solution;
PHP5.3 seem to have kerning problems when printing text:
Look at the 'x' in the following examples (font: Ubuntu-M.ttf):
PHP5.2, ubuntu (good)
PHP5.3.2, ubuntu (worse, x is fattened)
PHP5.3.2, MAMP OSX (horrible)
Is there any solution to this?
Anyone with 5.3.6 installed care to try this?
regards, //t
I attempted to replicate the middle image with my home machine after downloading the font (version 0.71.2 of Ubuntu font family). Arch Linux, x86_64, PHP 5.3.6, GD 2.0.34 (bundled), Suhosin patch, FreeType 2.4.4. I had better kerning on both e and x.
Image generation:
<?php
$img = imagecreatetruecolor(158, 72);
imagesavealpha($img, true);
$bg = imagecolorallocatealpha($img, 0, 0, 0, 127);
$black = imagecolorallocate($img, 0, 0, 0);
imagefill($img, 0, 0, $bg);
$text = "testar text"; // - was attempt at no aa, like example
imagettftext($img, 24, 0, 0, 36, -($black), 'Ubuntu-M', $text);
$text = "med text";
imagefttext($img, 24, 0, 12, 72, $black, 'Ubuntu-M', $text);
imagepng($img, 'test.png');
imagedestroy($img);
?>
Output:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With