note 22211 added to function.imagestring

From: Date: Mon, 10 Jun 2002 23:25:28 +0000
Subject: note 22211 added to function.imagestring
Groups: php.notes 
Request: Send a blank email to php-notes+get-31676@lists.php.net to get a copy of this message
Width ImageString, the strings you draw are not automatically wrapped width the edge of the image. You may use this function to automatically wrap them: function ImageStringWrap($image, $font, $x, $y, $text, $color, $maxwidth) { $fontwidth = ImageFontWidth($font); $fontheight = ImageFontHeight($font); if ($maxwidth != NULL) { $maxcharsperline = floor($maxwidth / $fontwidth); $text = wordwrap($text, $maxcharsperline, "\n", 1); } $lines = explode("\n", $text); while (list($numl, $line) = each($lines)) { ImageString($image, $font, $x, $y, $line, $color); $y += $fontheight; } } So, in particular, if you want to wrap a text with the edge of the Image, you may do: ImageStringWrap($img, $font, 0, $y, $text, $color, ImageSX($img) ); -- http://www.php.net/manual/en/function.imagestring.php http://master.php.net/manage/user-notes.php?action=edit+22211 http://master.php.net/manage/user-notes.php?action=delete+22211 http://master.php.net/manage/user-notes.php?action=reject+22211

« previous php.notes (#31676) next »