GD imagettftext not correct

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
logy
Forum Newbie
Posts: 3
Joined: Fri Nov 07, 2003 4:26 pm

GD imagettftext not correct

Post 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
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

It's a size problem by the looks of it.... try reducing or increasing the size slightly to see what happens.
logy
Forum Newbie
Posts: 3
Joined: Fri Nov 07, 2003 4:26 pm

Post 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?
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post 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.
logy
Forum Newbie
Posts: 3
Joined: Fri Nov 07, 2003 4:26 pm

Post by logy »

with arial or another font I also get such a ugly pixelized result. :(
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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.
Post Reply