Possible bug with imagettftext and imageft text when imagealphablending is false
| From: | Ethilien | Date: | Wed, 12 Oct 2005 20:02:32 +0000 |
| Subject: | Possible bug with imagettftext and imageft text when imagealphablending is false | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-223982@lists.php.net to get a copy of this message | ||
I have been attempting to write a dynamic text replacement script that would generate transparent PNGs using gd, and it works fine except when one of the characters in a font has parts of it that overhang into the previous characters. You can see what I mean in this test script:
<?php
$img = imagecreatetruecolor(200, 200);
imagealphablending($img, false);
$trans = imagecolortransparent($img);
imagefilledrectangle($img, 0, 0, 400, 400, $trans);
$green = imagecolorallocate($img, 6, 68, 0);
imagettftext($img, 30, 0, 10, 50, $green, "carolingia.ttf", "Linux");
header("Content-type: image/png");
imagesavealpha($img, true);
imagepng($img);
imagedestroy($img);
?>
The result can be seen at http://ethilien.net/tests/text.php
When you compare the text with what it should look like when I comment out the imagealphablending($img, false); line here http://ethilien.net/tests/text2.php you can see that the end of the 'u' is cut off.
I think that this is because the lower-left slash of the 'x' overlaps it and causes it to be overwritten.
This might be a bug in GD and not PHP, but I wanted to see if anyone has encountered this problem before or if I'm just not doing something right.
Thanks,
-Connor McKay