Page 1 of 1

GD imagettftext not correct

Posted: Fri Nov 07, 2003 4:26 pm
by logy
Hi..

I use this script to create a simple png-image:

Code: Select all

<?php
header ("Content-type: image/png");
$im = @imagecreate (500, 100);
$text_color = ImageColorAllocate ($im, 0, 0, 0); ImageTTFText ($im, 12, 0, 20, 60, $text_color, "path/verdana.ttf", "Text (GD with Antialiasing)");
$text_color = ImageColorAllocate ($im, 0, 0, 0); ImageTTFText ($im, 12, 0, 20, 80, - $text_color, "path/verdana.ttf", "Text (GD without Antialiasing)");
imagePNG ($im);
?>
Image

now the output differs to the original, and the question is, is GD not able to be better or exist a trick to fix this?

thx in adv

Posted: Fri Nov 07, 2003 5:09 pm
by Gen-ik
It's a size problem by the looks of it.... try reducing or increasing the size slightly to see what happens.

Posted: Fri Nov 07, 2003 6:14 pm
by logy
your right, it looks like a size problem but resize doesnt look better:

Image

Could it be, that I need a for GD adapted verdana.ttf? Or mayby there is somthing wrong with the dpi?

Posted: Fri Nov 07, 2003 7:03 pm
by Gen-ik
To be honest I'm not sure (doh). When I do use the TTF GD functions the fonts I use are either very stylised (unlike arial, verdana etc) or they are pixel fonts (which means no antialiasing looks very sharp).

The only thing I can suggest is try a different font like Arial just to see what difference it makes. There's not much difference between Arial and Verdana really (verdana's a bit wider) so it might be worth a shot.

Posted: Sat Nov 08, 2003 2:35 am
by logy
with arial or another font I also get such a ugly pixelized result. :(

Posted: Sat Nov 08, 2003 6:32 am
by JAM
My bet is that it's the GD version.

I got this on my local server (verdana=left, arial=right)
Image

...and this on my host's server
Image

Using the same script on both places of course.

Only thing not common that I can see is that I use GD2.15 and my host is not.