/** * @param ZendPage $page * @param string $text * @param float $x * @param float $y * @param AbstractText $format */ private function drawFormattedText(ZendPage $page, $text, $x, $y, AbstractText $format) { $fillStyle = $format->getFillStyle(); $strokeStyle = $format->getStrokeStyle(); $opacity = $format->getOpacity(); if (!$fillStyle->isVisible()) { $this->setLineStyle($page, $strokeStyle, $opacity); $this->drawRawText($page, $text, $x, $y, self::TEXT_DRAW_STROKE); } elseif (!$strokeStyle->isVisible()) { $this->setFillStyle($page, $fillStyle, $opacity); $this->drawRawText($page, $text, $x, $y, self::TEXT_DRAW_FILL); } elseif ($fillStyle->getOpacity() !== 1.0 || $strokeStyle->getOpacity() !== 1.0) { // separate fill and stroke to emulate correct alpha behavior $this->setFillStyle($page, $fillStyle, $opacity); $this->drawRawText($page, $text, $x, $y, self::TEXT_DRAW_FILL); $this->setLineStyle($page, $strokeStyle, $opacity); $this->drawRawText($page, $text, $x, $y, self::TEXT_DRAW_STROKE); } else { $this->setLineStyle($page, $strokeStyle); $this->setFillStyle($page, $fillStyle); $page->setAlpha($opacity); $this->drawRawText($page, $text, $x, $y, self::TEXT_DRAW_FILL_AND_STROKE); } }
/** * @param SimpleXMLElement $element * @param AbstractText $text */ private function addTextStyle(SimpleXMLElement $element, AbstractText $text) { $this->addFontStyle($element, $text->getFontStyle()); $this->addFillStyle($element, $text->getFillStyle()); $this->addStrokeStyle($element, $text->getStrokeStyle()); if ($text->getOpacity() < 1) { $element->addAttribute("opacity", $text->getOpacity()); } }