Bug #17151 Updated: ImageTTF* has stopped working
| From: | php-bugs at lists dot php dot net | Date: | Sun, 07 Jul 2002 05:00:08 +0000 |
| Subject: | Bug #17151 Updated: ImageTTF* has stopped working | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-13355@lists.php.net to get a copy of this message | ||
ID: 17151
Updated by: php-bugs@lists.php.net
Reported By: nick@asknick.com
-Status: Feedback
+Status: No Feedback
Bug Type: GD related
Operating System: Linux
PHP Version: 4.1.2
New Comment:
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
Previous Comments:
------------------------------------------------------------------------
[2002-06-06 22:15:31] mfischer@php.net
Can you, for the record, please tell us which freetype version you've
used before and after then set the status to closed? thx
------------------------------------------------------------------------
[2002-06-06 21:56:17] nick@asknick.com
Upgrading to the latest FreeType fixed the problem. Thanks, and sorry
for thinking it was PHP!
------------------------------------------------------------------------
[2002-05-15 01:11:54] Nick@asknick.com
I'll check and let you know - thanks!
------------------------------------------------------------------------
[2002-05-12 09:33:21] rasmus@php.net
PHP doesn't implement any of these low-level functions. They are
implemented by the GD and Freetype libraries. Did you change/upgrade
either of these?
------------------------------------------------------------------------
[2002-05-11 00:31:02] nick@asknick.com
ImageTTF* has stopped working the way it used to. I have sideways text
on my site, and it worked great under earlier versions of PHP (for an
example, please see http://AskNick.com, running under 4.0.6). Now,
under >=4.1.2, specifying any angle for the text other than 0 results
in a broken link (see http://SoundBytes.org - same code, running
under
4.1.2). Same code running under 4.2.0 can be seen on
http://sbarch.cob.rit.edu, but there I used a 45-degree
angle, which I
think illustrates the problem handily - each letter of the text is at
an incorrect 90 degrees, althought the angle of the text itself is the
correct 45 degrees. Had I used a 90-degree angle, then the letters
would have been individually upside down, but the text would have been
correctly vertical. Also, kerning between letters is way off at 90.
Here is the code I'm using on all three sites:
<?PHP
header("Content-Type: image/gif");
// GRAFTEXT
// takes:
// $title - the text of the title
// $titlecolor - the color of the title
// $titlefont - the font for the title
// $titlesize - font size of the title
// $rotation - the angle of the title - 0 = normal; 90 = straight up
// background will be transparent
// THIS FUNCTION UNHEXIZES A COLOR
function unhexize ($color) {
$color = hexdec($color);
$red = ($color&0xFF0000)>>16;
$green = ($color&0xFF00)>>8;
$blue = ($color&0xFF);
return array ($red, $green, $blue);
}
// determine font height.
$bbox = ImageTTFBBox($titlesize, $rotation, $titlefont, "W");
if ($rotation < 0) {
$font_height = abs($bbox[7]-$bbox[1]);
} else if ($rotation > 0) {
$font_height = abs($bbox[1]-$bbox[7]);
} else {
$font_height = abs($bbox[7]-$bbox[1]);
}
// determine bounding box.
$bbox = ImageTTFBBox($titlesize, $rotation, $titlefont, $title);
if ($rotation < 0) {
$width = abs($bbox[4]-$bbox[0]);
$height = abs($bbox[3]-$bbox[7]);
$offset_y = $font_height;
$offset_x = 0;
} else if ($rotation > 0) {
$width = abs($bbox[2]-$bbox[6]);
$height = abs($bbox[1]-$bbox[5]);
$offset_y = abs($bbox[7]-$bbox[5])+$font_height;
$offset_x = abs($bbox[0]-$bbox[6]);
} else {
$width = abs($bbox[4]-$bbox[6]);
$height = abs($bbox[7]-$bbox[1]);
$offset_y = $font_height;
$offset_x = 0;
}
$bgc = unhexize($titlecolor);
$im = ImageCreate($width+3,$height+3);
$backcolor = ImageColorAllocate($im, 255, 255, 255);
$trans = ImageColorTransparent($im, $backcolor);
$titlecolor = ImageColorAllocate($im, $bgc[0], $bgc[1], $bgc[2]);
$white = ImageColorAllocate($im, 255, 255, 255);
$green = ImageColorAllocate($im, 0, 191, 0);
$brown = ImageColorAllocate($im, 128, 0, 0);
$blue = ImageColorAllocate($im, 0, 0, 255);
ImageTTFText($im, $titlesize, $rotation, $offset_x, $offset_y,
$titlecolor, $titlefont, $title);
ImagePNG($im);
ImageDestroy($im);
?>
You call it with:
<?PHP
$title = "TextGoesHere";
echo "<IMG
SRC=\"/includes/graftext.php?title=$title&titlecolor=$titlecolor&titlefont=$titlefont&titlesize=$titlesize&rotation=$rotation\"
ALT=\"$title\">";
?>
Thanks for any light you can shed on this problem!
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=17151&edit=1