note 39781 deleted from function.imagettfbbox by cmb

From: Date: Sun, 04 Dec 2016 12:01:13 +0000
Subject: note 39781 deleted from function.imagettfbbox by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208172@lists.php.net to get a copy of this message
Note Submitter: David Eder ---- 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; }

« previous php.notes (#208172) next »