protected function text() { if ($this->text) { $x = $this->fontPadding; $y = $this->fontPadding; switch ($this->fontAlignHorizontal) { case 'center': $x = $this->image->getWidth() / 2; $this->fontAlignHorizontal = 'center'; break; case 'right': $x = $this->image->getWidth() - 3 - $this->fontPadding; $this->fontAlignHorizontal = 'right'; break; } switch ($this->fontAlignVertical) { case 'middle': $y = $this->image->getHeight() / 2 + $this->fontPadding; $this->fontAlignVertical = 'middle'; break; case 'bottom': $y = $this->image->getHeight() - 4 - $this->fontPadding; break; } $this->image->text($this->text, $x, $y, function ($font) { /* @var $font \Intervention\Image\Imagick\Font */ $fontType = $_ENV['base_path'] . 'fonts' . DIRECTORY_SEPARATOR . $this->font . ".ttf"; $font->file($fontType); $font->color('#' . $this->fontColor); $font->size($this->fontSize); $font->valign($this->fontAlignVertical); $font->align($this->fontAlignHorizontal); if ($this->fontFit == 'max') { $maxWidth = $this->image->getWidth(); $fontSize = $this->fontSize; while (true) { $font->size($fontSize); $metrics = $this->getResourceSize($fontType, $this->text, $fontSize, 0); if ($metrics['width'] <= $maxWidth) { break; } $fontSize = (double) $fontSize - 0.1; if ($fontSize <= 0) { break; } } } }); } }
/** * @param Image $image * @param NodeInfo $node */ protected function writeContent(Image $image, NodeInfo $node) { $content = $node->content(); $rect = $node->rectangle(); foreach ($content->content() as $line) { $image->text($line[0], $rect->left + $line[1], $rect->top + $line[2], function (AbstractFont $font) use($line) { $font->color($line[4]); $font->size($line[3]); $font->align($line[5]); $font->valign($line[6]); $font->file(static::$fontPath); }); } }
/** * Write text in current image * * @param string $text * @param integer $pos_x * @param integer $pos_y * @param integer $angle * @param integer $size * @param string $color * @param string $fontfile * @return \Intervention\Image\Image * @static */ public static function text($text, $pos_x = 0, $pos_y = 0, $size = 16, $color = '000000', $angle = 0, $fontfile = null) { return \Intervention\Image\Image::text($text, $pos_x, $pos_y, $size, $color, $angle, $fontfile); }
/** * Compatibility method to decide old or new style of text writing * * @param string $text * @param integer $posx * @param integer $posy * @param mixed $size_or_callback * @param string $color * @param integer $angle * @param string $fontfile * @return \Intervention\Image\Image * @static */ public static function text($text, $posx = 0, $posy = 0, $size_or_callback = null, $color = '000000', $angle = 0, $fontfile = null) { return \Intervention\Image\Image::text($text, $posx, $posy, $size_or_callback, $color, $angle, $fontfile); }
protected function paymentInformation() { $multiplier = 0; if ($this->order->getDueDate()) { $this->image->text('', 1445, 710 + $multiplier * 55, function (Font $font) { $font->color($this->template->getPrimaryColor()); $font->file($this->template->getIconFont()); $font->size(37); }); $this->image->text($this->translate('dueDate') . ':', 1520, 705 + $multiplier * 55, function (Font $font) { $font->color($this->template->getPrimaryColor()); $font->size(27); $font->file($this->template->getFont()); }); $this->image->text($this->order->getDueDate()->format('d/m/Y'), 1850, 705 + $multiplier * 55, function (Font $font) { $font->size(27); $font->file($this->template->getFont()); $font->color($this->template->getFontColor()); }); $multiplier++; } if ($this->order->getAccount()->getAccountNumber()) { $this->image->text('', 1445, 710 + $multiplier * 55, function (Font $font) { $font->color($this->template->getPrimaryColor()); $font->file($this->template->getIconFont()); $font->size(37); }); $this->image->text($this->translate('accountNumber') . ':', 1520, 705 + $multiplier * 55, function (Font $font) { $font->color($this->template->getPrimaryColor()); $font->size(27); $font->file($this->template->getFont()); }); $this->image->text($this->order->getAccount()->getAccountNumber(), 1850, 705 + $multiplier * 55, function (Font $font) { $font->size(27); $font->file($this->template->getFont()); $font->color($this->template->getFontColor()); }); $multiplier++; } if ($this->order->getAccount()->getIBan()) { $this->image->text('', 1445, 710 + $multiplier * 55, function (Font $font) { $font->color($this->template->getPrimaryColor()); $font->file($this->template->getIconFont()); $font->size(37); }); $this->image->text(Strings::upper($this->translate('iban')) . ':', 1520, 705 + $multiplier * 55, function (Font $font) { $font->color($this->template->getPrimaryColor()); $font->size(27); $font->file($this->template->getFont()); }); $this->image->text($this->order->getAccount()->getIBan(), 1850, 705 + $multiplier * 55, function (Font $font) { $font->size(27); $font->file($this->template->getFont()); $font->color($this->template->getFontColor()); }); $multiplier++; } if ($this->order->getAccount()->getSwift()) { $this->image->text('', 1445, 710 + $multiplier * 55, function (Font $font) { $font->color($this->template->getPrimaryColor()); $font->file($this->template->getIconFont()); $font->size(37); }); $this->image->text(Strings::upper($this->translate('swift')) . ':', 1520, 705 + $multiplier * 55, function (Font $font) { $font->color($this->template->getPrimaryColor()); $font->size(27); $font->file($this->template->getFont()); }); $this->image->text($this->order->getAccount()->getSwift(), 1850, 705 + $multiplier * 55, function (Font $font) { $font->size(27); $font->file($this->template->getFont()); $font->color($this->template->getFontColor()); }); $multiplier++; } if ($this->order->getPayment()->getVariableSymbol()) { $this->image->text('', 1455, 710 + $multiplier * 55, function (Font $font) { $font->color($this->template->getPrimaryColor()); $font->file($this->template->getIconFont()); $font->size(37); }); $this->image->text($this->translate('varSymbol') . ':', 1520, 705 + $multiplier * 55, function (Font $font) { $font->color($this->template->getPrimaryColor()); $font->size(27); $font->file($this->template->getFont()); }); $this->image->text($this->order->getPayment()->getVariableSymbol(), 1850, 705 + $multiplier * 55, function (Font $font) { $font->size(27); $font->file($this->template->getFont()); $font->color($this->template->getFontColor()); }); $multiplier++; } if ($this->order->getPayment()->getConstantSymbol()) { $this->image->text('', 1455, 710 + $multiplier * 55, function (Font $font) { $font->color($this->template->getPrimaryColor()); $font->file($this->template->getIconFont()); $font->size(37); }); $this->image->text($this->translate('constSymbol') . ':', 1520, 705 + $multiplier * 55, function (Font $font) { $font->color($this->template->getPrimaryColor()); $font->size(27); $font->file($this->template->getFont()); }); $this->image->text($this->order->getPayment()->getConstantSymbol(), 1850, 705 + $multiplier * 55, function (Font $font) { $font->size(27); $font->file($this->template->getFont()); $font->color($this->template->getFontColor()); }); $multiplier++; } $this->image->text('', 1445, 710 + $multiplier * 55, function (Font $font) { $font->color($this->template->getPrimaryColor()); $font->file($this->template->getIconFont()); $font->size(37); }); $this->image->text($this->translate('totalPrice') . ':', 1520, 705 + $multiplier * 55, function (Font $font) { $font->color($this->template->getPrimaryColor()); $font->size(27); $font->file($this->template->getFont()); }); $this->image->text($this->formatNumber($this->getTotalPrice(TRUE)) . ' ' . $this->order->getPayment()->getCurrency(), 1850, 705 + $multiplier * 55, function (Font $font) { $font->size(27); $font->file($this->template->getFont()); $font->color($this->template->getFontColor()); }); }