I think I've finally figured out how to implement some of the TTF image functions in the GD library, and I thought others out there would like to save some time.
The problem with understanding the imageTTFbbox and imageTTFtext functions stem from correctly positioning the font within the box.
Here's my code sample that at least solved it for me.
<?
Header ("Content-type: image/gif");
$font = "fonts/TIMES.TTF";
$padding = 5; // set this to whatever you like
$text = "Sample text with a y,j,p,etc.
$dim = imageTTFbbox($size,0,$font,$text);
$width = abs($dim[2] - $dim[0]) + $padding;
$height = abs($dim[1] - $dim[7]) + $padding;
$amtleftofBL = $dim[0];
$amtbelowBL = $dim[1];
$xcoord = (int)($padding/2) - $amtleftofBL;
$ycoord = $height - $amtbelowBL - ((int)(($padding/2)+2.5)); // the 2.5 is arbitrary. I just chose something that looked nice and consistent.
$im = imagecreate ($width, $height);
$black = ImageColorAllocate ($im, 0, 0, 0);
$white = ImageColorAllocate ($im, 255, 255, 255);
ImageTTFText ($im, $size, 0, $xcoord, $ycoord, $white, $font, $text);
ImageGif ($im);
ImageDestroy ($im);
?>
Hope this helps someone.
Dave