Need help with imagettfbbox function

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
nettest1234
Forum Newbie
Posts: 1
Joined: Wed Jun 30, 2004 8:36 am

Need help with imagettfbbox function

Post by nettest1234 »

Hi,

I used imagettfbbox function for calculating text width and my code was:-
-----------------------------------------

$bbox = imagettfbbox($font_size, 0, $font_file, $text_string);

$width_text = abs($bbox[4] - $bbox[6]); # width of the text

$height_text = abs($bbox[7] - $bbox[1]); # height of the text

-----------------------------------------

I am getting height value correct, but wrong width value, the width value being returned is more than what is actual value, the error gap increases with font size and/or text length

Please tell me why is this happening and also the solution.

Thanks
Post Reply