Esempio n. 1
0
 /**
  * @param Image $image
  * @param string $text
  * @param Coords $coords
  * @param AddTextParams $params
  */
 public function addText(Image $image, $text, Coords $coords, AddTextParams $params)
 {
     $placeWidth = $params->width === null ? $image->getWidth() - $coords->getX() : $params->width;
     $this->lastCoords = $coords;
     $lines = $this->getLines($text, $placeWidth, $params);
     if (count($lines) == 0) {
         return;
     }
     if ($params->expandSide == AddTextParams::EXPAND_HEIGHT) {
         $newHeight = $coords->getY() + count($lines) * $params->lineHeight;
         if ($newHeight > $image->getHeight()) {
             $image->resizeCanvasHeight($newHeight);
         }
     }
     foreach ($lines as $line) {
         $this->renderLine($image, $params, $line, $placeWidth);
     }
 }