コード例 #1
0
ファイル: WithMap.php プロジェクト: sacredwebsite/vtigercrm
 /**
  * Writes text
  *
  * Parameter array:
  * 'x': int X-point of text
  * 'y': int Y-point of text
  * 'text': string The text to add
  * 'alignment': array [optional] Alignment
  * 'color': mixed [optional] The color of the text
  */
 function addText($params)
 {
     if (isset($this->_imageMap)) {
         $this->_imageMap->addText($params);
     }
     parent::addText($params);
 }
コード例 #2
0
ファイル: SVG.php プロジェクト: Spark-Eleven/revive-adserver
 /**
  * Writes text
  *
  * Parameter array:
  * 'x': int X-point of text
  * 'y': int Y-point of text
  * 'text': string The text to add
  * 'alignment': array [optional] Alignment
  * 'color': mixed [optional] The color of the text
  */
 function addText($params)
 {
     $x = $this->_getX($params['x']);
     $y = $this->_getY($params['y']);
     $text = $params['text'];
     $color = isset($params['color']) ? $params['color'] : false;
     $alignment = isset($params['alignment']) ? $params['alignment'] : false;
     $textHeight = $this->textHeight($text);
     if (!is_array($alignment)) {
         $alignment = array('vertical' => 'top', 'horizontal' => 'left');
     }
     if (!isset($alignment['vertical'])) {
         $alignment['vertical'] = 'top';
     }
     if (!isset($alignment['horizontal'])) {
         $alignment['horizontal'] = 'left';
     }
     $align = '';
     if (isset($this->_font['vertical']) && $this->_font['vertical']) {
         //            $align .= 'writing-mode: tb-rl;';
         if ($alignment['vertical'] == 'bottom') {
             $align .= 'text-anchor:end;';
             //$y = $y + $textHeight;
         } elseif ($alignment['vertical'] == 'center') {
             //$y = $y + ($textHeight / 2);
             $align .= 'text-anchor:middle;';
         }
     } else {
         if ($alignment['horizontal'] == 'right') {
             $align .= 'text-anchor:end;';
         } elseif ($alignment['horizontal'] == 'center') {
             $align .= 'text-anchor:middle;';
         }
         if ($alignment['vertical'] == 'top') {
             $y = $y + $textHeight;
         } elseif ($alignment['vertical'] == 'center') {
             $y = $y + $textHeight / 2;
         }
     }
     if ($color === false && isset($this->_font['color'])) {
         $color = $this->_font['color'];
     }
     $textColor = $this->_color($color);
     $textOpacity = $this->_opacity($color);
     $this->_addElement('<g transform="translate(' . round($x) . ', ' . round($y) . ')">' . "\n" . $this->_indent . '    <text ' . 'x="0" ' . 'y="0" ' . (isset($this->_font['angle']) && $this->_font['angle'] > 0 ? 'transform="rotate(' . $this->_font['angle'] . ')" ' : '') . 'style="' . (isset($this->_font['name']) ? 'font-family:' . $this->_font['name'] . ';' : '') . 'font-size:' . $this->_font['size'] . 'px;fill:' . $textColor . ($textOpacity ? ';fill-opacity:' . $textOpacity : '') . ';' . $align . '">' . htmlspecialchars($text) . '</text>' . "\n" . $this->_indent . '</g>', $params);
     parent::addText($params);
 }
コード例 #3
0
ファイル: PDF.php プロジェクト: ballistiq/revive-adserver
 /**
  * Writes text
  *
  * Parameter array:
  * 'x': int X-point of text
  * 'y': int Y-point of text
  * 'text': string The text to add
  * 'alignment': array [optional] Alignment
  * 'color': mixed [optional] The color of the text
  */
 function addText($params)
 {
     $x = $this->_getX($params['x']);
     $y = $this->_getY($params['y']);
     $text = $params['text'];
     $color = isset($params['color']) ? $params['color'] : false;
     $alignment = isset($params['alignment']) ? $params['alignment'] : false;
     $this->_setFont();
     $textWidth = $this->textWidth($text);
     $textHeight = $this->textHeight($text);
     if (!is_array($alignment)) {
         $alignment = array('vertical' => 'top', 'horizontal' => 'left');
     }
     if (!isset($alignment['vertical'])) {
         $alignment['vertical'] = 'top';
     }
     if (!isset($alignment['horizontal'])) {
         $alignment['horizontal'] = 'left';
     }
     if ($alignment['horizontal'] == 'right') {
         $x = $x - $textWidth;
     } elseif ($alignment['horizontal'] == 'center') {
         $x = $x - $textWidth / 2;
     }
     if ($alignment['vertical'] == 'top') {
         $y = $y + $textHeight;
     } elseif ($alignment['vertical'] == 'center') {
         $y = $y + $textHeight / 2;
     }
     if ($color === false && isset($this->_font['color'])) {
         $color = $this->_font['color'];
     }
     pdf_show_xy($this->_pdf, $text, $this->_getX($x), $this->_getY($y));
     parent::addText($params);
 }
コード例 #4
0
ファイル: SWF.php プロジェクト: roojs/pear
 /**
  * Writes text
  *
  * Parameter array:
  * 'x'     : int X-point of text
  * 'y'     : int Y-point of text
  * 'text'  : string The text to add
  * 'color' : mixed [optional] The color of the text
  *
  * @param array $params Parameter array
  *
  * @todo Vertical alignment
  * @return void
  */
 function addText($params)
 {
     $x0 = $this->_getX($params['x']);
     $y0 = $this->_getY($params['y']);
     $text = str_replace("\r", '', $params['text']);
     $color = isset($params['color']) ? $params['color'] : false;
     $textHeight = $this->textHeight($text);
     $alignment = isset($params['alignment']) ? $params['alignment'] : false;
     if (!is_array($alignment)) {
         $alignment = array('vertical' => 'top', 'horizontal' => 'left');
     }
     if (!isset($alignment['vertical'])) {
         $alignment['vertical'] = 'top';
     }
     if (!isset($alignment['horizontal'])) {
         $alignment['horizontal'] = 'left';
     }
     if ($color === false && isset($this->_font['color'])) {
         $color = $this->_font['color'];
     }
     if ($color == 'transparent') {
         return;
     }
     if (strpos($this->_font['file'], '.') === false) {
         $this->_font['file'] = IMAGE_CANVAS_SYSTEM_FONT_PATH . $this->_font['file'] . '.fdb';
     }
     $textColor = $this->_color($color);
     $textOpacity = $this->_opacity($color);
     $lines = explode("\n", $text);
     foreach ($lines as $line) {
         $x = $x0;
         $y = $y0;
         $y0 += $textHeight + 2;
         $width = $this->textWidth($line);
         $height = $this->textHeight($line);
         if ($alignment['horizontal'] == 'right') {
             $x -= $width;
         } else {
             if ($alignment['horizontal'] == 'center') {
                 $x -= $width / 2;
             }
         }
         $font = new SWFFont($this->_font['file']);
         $text = new SWFText();
         $text->setFont($font);
         $text->moveTo($x, $y + $this->_font['size']);
         $text->setColor($textColor[0], $textColor[1], $textColor[2], $textOpacity);
         $text->setHeight($this->_font['size']);
         $text->addString($line);
         $this->_canvas->add($text);
     }
     parent::addText($params);
 }