note 89505 added to function.imagettftext

From: Date: Wed, 11 Mar 2009 14:40:44 +0000
Subject: note 89505 added to function.imagettftext
Groups: php.notes 
Request: Send a blank email to php-notes+get-151736@lists.php.net to get a copy of this message
Here's a simple function to wrap text going into an image. It'll wrap onto as many lines as it needs to, but $angle has to be zero. The $width parameter is the width of the image. <?php function wrap($fontSize, $angle, $fontFace, $string, $width){ $ret = ""; $arr = explode(' ', $string); foreach ( $arr as $word ){ $teststring = $ret.' '.$word; $testbox = imagettfbbox($fontSize, $angle, $fontFace, $teststring); if ( $testbox[2] > $width ){ $ret.=($ret==""?"":"\n").$word; } else { $ret.=($ret==""?"":' ').$word; } } return $ret; } ?> ---- Server IP: 92.48.74.199 Probable Submitter: 78.86.184.210 ---- Manual Page -- http://www.php.net/manual/en/function.imagettftext.php Edit -- https://master.php.net/note/edit/89505 Del: integrated -- https://master.php.net/note/delete/89505/integrated Del: useless -- https://master.php.net/note/delete/89505/useless Del: bad code -- https://master.php.net/note/delete/89505/bad+code Del: spam -- https://master.php.net/note/delete/89505/spam Del: non-english -- https://master.php.net/note/delete/89505/non-english Del: in docs -- https://master.php.net/note/delete/89505/in+docs Del: other reasons-- https://master.php.net/note/delete/89505 Reject -- https://master.php.net/note/reject/89505 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#151736) next »