I'm trying to understand how to work with bounding boxes around text with
the GD2 library. I thought I understood the concepts and wrote a simple
program to make sure. Here it is:
<?php
putenv('GDFONTPATH=c:\windows\fonts');
$bbox=imagettfbbox(10,0,"arial.ttf","Hello World");
echo "upper left ($bbox[6],$bbox[7])-----upper right
($bbox[4],$bbox[5])<br><br>";
echo "lower left ($bbox[0],$bbox[1])-----lower right ($bbox[2],$bbox[3])";
?>
The idea is for me to find out the bounding box coordinates for a Hellow
World message. The output produced has me very confused though. It shows
the coordinates as follows:
upper left (-1,-10)-----upper right (66,-10)
lower left (-1,-1)-----lower right (66,-1)
I understand how the lower left coordinate can be -1,-1, and the lower right
coordinate seems logical, too.
How, though, can the upper coordinates have y values of -10? That's below
the baseline! It would seem logical that since I specified a font size of
10 my Y coordinates on the top would be roughly 10 more than the y
coordinates of the lower corners. So, I'd expect the upper coordinates to
be something like (-1,10) and (66,10). Where is the negative 10 coming
from?
Tony