0) { $metrics = $image->queryFontMetrics($draw, implode(' ', array_slice($words, 0, ++$i))); $lineHeight = max($metrics['textHeight'], $lineHeight); // check if we have found the word that exceeds the line width if ($metrics['textWidth'] > $maxWidth or count($words) < $i) { // handle case where a single word is longer than the allowed line width (just add this as a word on its own line?) if ($i == 1) $i++; $lines[] = implode(' ', array_slice($words, 0, --$i)); $words = array_slice($words, $i); $i = 0; } } return array($lines, $lineHeight); } function drawContact($draw, $image, $font, $size, $color, $x, $y, $contact_type, $contact_text) { switch ($contact_type) { case 'email': $icon = html_entity_decode("", ENT_COMPAT, 'UTF-8'); break; case 'address': $icon = html_entity_decode("", ENT_COMPAT, 'UTF-8'); break; case 'telephone': $icon = html_entity_decode("", ENT_COMPAT, 'UTF-8'); break; case 'website': $icon = html_entity_decode("", ENT_COMPAT, 'UTF-8'); break; default: $icon = html_entity_decode("", ENT_COMPAT, 'UTF-8'); } $draw->setFontSize(16); $draw->setFillColor(new ImagickPixel('#333333')); // Draw icon $draw->setFont('fonts/fontawesome-webfont.ttf'); $image->annotateImage($draw, $x + 20, $y , 0, $icon); // Draw contact text $draw->setFont('fonts/OpenSans-Light.ttf'); $image->annotateImage($draw, $x + 45, $y, 0, $contact_text); $bottom = $y + 20; return $bottom; } function drawMarker($draw, $image, $color, $x, $y, $size) { $draw->setFont('fonts/fontawesome-webfont.ttf'); $icon = html_entity_decode("", ENT_COMPAT, 'UTF-8'); $draw->setFontSize($size); $draw->setFillColor($color); $image->annotateImage($draw, $x, $y, 0, $icon); } function drawRectangle($draw, $image, $x1, $y1, $x2, $y2, $color, $opacity) { $draw->setFillColor($color); $draw->setFillOpacity($opacity); $draw->rectangle($x1, $y1, $x2, $y2); $image->drawImage($draw); } function drawWrapedText($draw, $image, $font, $size, $color, $x, $y, $wrap_width, $text) { $draw->setFont($font); $draw->setFontSize($size); $draw->setFillColor($color); list($lines, $lineHeight) = wordWrapAnnotation($image, $draw, $text, $wrap_width); for($i = 0; $i < count($lines); $i++) { $image->annotateImage($draw, $x, $y + ($i * $lineHeight), 0, $lines[$i]); } $bottom = $y + ($i * $lineHeight); return $bottom; } ?>