|
Posted by Ethilien on 10/12/05 23:02
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
Navigation:
[Reply to this message]
|