note 39781 added to function.imagettfbbox
| From: | DavidEder at rn2 dot php dot net | Date: | Tue, 10 Feb 2004 14:46:52 +0000 |
| Subject: | note 39781 added to function.imagettfbbox | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-64957@lists.php.net to get a copy of this message | ||
As "oliver dot martin at onemail dot at" noted above, imagettfbbox() does not work
correctly in php 4.3.4. To remedy this, I've written a short function that uses trig to
calculate the bounding box from rotating a non-rotated piece of text.
Hopefully, this comment will be obsolete soon, but for now, ...
function imagettfbbox_t($size, $angle, $fontfile, $text)
{
// compute size with a zero angle
$coords = imagettfbbox($size, 0, $fontfile, $text);
// convert angle to radians
$a = $angle * M_PI / 180;
// compute some usefull values
$ca = cos($a);
$sa = sin($a);
$ret = array();
// perform transformations
for($i = 0; $i < 7; $i += 2)
{
$ret[$i] = round($coords[$i] * $ca + $coords[$i+1] * $sa);
$ret[$i+1] = round($coords[$i+1] * $ca - $coords[$i] * $sa);
}
return $ret;
}
----
Manual Page -- http://www.php.net/manual/en/function.imagettfbbox.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39781
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39781&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39781&report=yes
Search -- http://master.php.net/manage/user-notes.php