Bug #1987: ImageTTFBBox does not return correct bounding box.
| From: | animate2 at underworld dot net | Date: | Sat, 07 Aug 1999 06:13:50 +0000 |
| Subject: | Bug #1987: ImageTTFBBox does not return correct bounding box. | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-9609@lists.php.net to get a copy of this message | ||
From: animate2@underworld.net
Operating system: Linux 2.2.10
PHP version: 3.0.12
PHP Bug Type: Misbehaving function
Bug description: ImageTTFBBox does not return correct bounding box.
ImageTTFBBox doesn't return a correct bounding box. In many cases, an image created to be the
size of a bounding box will not be tall enough and cuts off part of the text it is meant to contain
(in most cases, the bottoms of g's, p's, and other characters with drop-down loopy
things). In some occasions, the width of a bounding box will also be inadequate. The following
function illustrates:
function GIFheadline ($font, $fontsize, $bulletgif, $text, $number) {
$bounds = ImageTTFBBox($fontsize, 0, $font, $text);
$imagewidth = abs($bounds[2] - $bounds[0]);
$imageheight = abs($bounds[1] - $bounds[7]);
$image = imagecreate($imagewidth, $imageheight);
$textcolor = ImageColorAllocate($image, 98,128,190);
imagettftext($image, $fontsize, 0, 0, $imageheight, $textcolor, $font, $text);
imagegif($image, "$number.gif");
}