ZFGC
Resources => Coding => Topic started by: AleX_XelA on October 31, 2006, 03:41:13 pm
-
Hey there guys, lately I've been toying around with the GD library, and more precisely writting text on top of an image. As you may already know, there's a function that lets you use a .ttf font "ImageTTFText". The thing is, this function anti-aliases the text, and I don't want that to happen. Can anyone help me?
I'm not sure if it's the anti-aliasing that makes it so bad, but if I write the same thing in Paint, with the same size, it won't look the same.
(http://img288.imageshack.us/img288/6724/testfb8.png)
On the left side is the text generated by the PHP code, which calls the Verdana font, and sets the size to "7". On the right side, is the font created using MSPaint, Verdana, size "7".
How can I fix this so it looks like the Paint output?
-
try using a negative color index
$textColour = ImageColorAllocate($image, 255, 255, 255);
ImageTTFText($image, 8, 0, 0, 0, -$textColour, $font, $text);
-
It's better, but I still don't get the exact result I want, at least the anti-aliasing is gone, but the shape of the letters is not the same. I wonder how I could fix that?
-
Sol, I'm testing this locally, so that can't be the reason :S The more I think about this problem, the more I have a headache...
Edit : Oh if you have a complete other solution to this problem, like using another function or even another library, please tell!
-
It might help us (Yes, very simple code, but still) if you post the code. It could be that the background color or other elements are somehow effecting the way it looks.
-
Sure thing, here you go :
<?php
header ("Content-type: image/png"); ImageTTFText ($image, 7, 0, 23, 17, -$txt_color, "/font/verdana.ttf", "Test"); ?>
test.png is just a square with the same color as the one shown in the first post.
-
after testing that code, i just can't see what the problem is, when i do it, it almost looks exactly like the one in paint (except there's a 1 pixel difference between the 't' and 'est')