note 92112 modified in function.imagickdraw-annotation by danbrown

From: Date: Thu, 09 Jul 2009 14:02:18 +0000
Subject: note 92112 modified in function.imagickdraw-annotation by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-158106@lists.php.net to get a copy of this message
may help someone... <?php /** * Split the given text into rows fitting the given maxWidth * * @param unknown_type $draw * @param unknown_type $text * @param unknown_type $maxWidth * @return array */ private function getTextRows($draw, $text, $maxWidth) { $words = explode(" ", $text); $lines = array(); $i=0; while ($i < count($words)) {//as long as there are words $line = ""; do {//append words to line until the fit in size if($line != ""){ $line .= " "; } $line .= $words[$i]; $i++; if(($i) == count($words)){ break;//last word -> break } //messure size of line + next word $linePreview = $line." ".$words[$i]; $metrics = $this->canvas->queryFontMetrics($draw, $linePreview); //echo $line."($i)".$metrics["textWidth"].":".$maxWidth."<br>"; }while($metrics["textWidth"] <= $maxWidth); //echo "<hr>".$line."<br>"; $lines[] = $line; } //var_export($lines); return $lines; } ?> --was-- may help someone... /** * Split the given text into rows fitting the given maxWidth * * @param unknown_type $draw * @param unknown_type $text * @param unknown_type $maxWidth * @return array */ private function getTextRows($draw, $text, $maxWidth) { $words = explode(" ", $text); $lines = array(); $i=0; while ($i < count($words)) {//as long as there are words $line = ""; do {//append words to line until the fit in size if($line != ""){ $line .= " "; } $line .= $words[$i]; $i++; if(($i) == count($words)){ break;//last word -> break } //messure size of line + next word $linePreview = $line." ".$words[$i]; $metrics = $this->canvas->queryFontMetrics($draw, $linePreview); //echo $line."($i)".$metrics["textWidth"].":".$maxWidth."<br>"; }while($metrics["textWidth"] <= $maxWidth); //echo "<hr>".$line."<br>"; $lines[] = $line; } //var_export($lines); return $lines; } http://php.net/manual/en/function.imagickdraw-annotation.php

« previous php.notes (#158106) next »