note 31339 deleted from function.imagettfbbox by sniper

From: Date: Fri, 07 Nov 2003 12:41:34 +0000
Subject: note 31339 deleted from function.imagettfbbox by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-60082@lists.php.net to get a copy of this message
Note Submitter: shamblrd@hotmail.com ---- This handy function will split a string into an array of strings that fit a given line width for imagettftext, splitting at spaces. The parameters are the text string itself, the font size, the font file and the desired max width in pixels. function text_to_lines($text, $size, $font, $width) { $ex = explode(" ", $text); $ex_c = count($ex); $p = 0; for($i=0; $i<$ex_c; $i++) { if($i) $test = $full[$p]." "; $test .= $ex[$i]; $bbox = imagettfbbox($size, 0, $font, $test); if(($bbox[4] - $bbox[6]) > $width) { $p++; $full[$p] = $ex[$i]; } else $full[$p] = $test; } return $full; }

« previous php.notes (#60082) next »