Exemplo n.º 1
0
	/**
	 * Draw a string
	 *
	 * @var awText $text Text to print
	 * @param awPoint $point Draw the text at this point
	 */
	public function string(awText $text, awPoint $point) {
		
		$font = $text->getFont();
		
		if($text->getBackground() !== NULL or $text->border->visible()) {
		
			list($left, $right, $top, $bottom) = $text->getPadding();
			
			$width = $font->getTextWidth($text);
			$height = $font->getTextHeight($text);
			
			$x1 = floor($point->x - $left);
			$y1 = floor($point->y - $top);
			$x2 = $x1 + $width + $left + $right;
			$y2 = $y1 + $height + $top + $bottom;
			
			$this->filledRectangle(
				$text->getBackground(),
				awLine::build($x1, $y1, $x2, $y2)
			);
			
			$text->border->rectangle(
				$this,
				new awPoint($x1 - 1, $y1 - 1),
				new awPoint($x2 + 1, $y2 + 1)
			);
			
		}
		
		$font->draw($this, $point, $text);
		
	}
Exemplo n.º 2
0
 public function string(awText $text, awPoint $point, $width = NULL)
 {
     $font = $text->getFont();
     // Can we deal with that font?
     if ($this->isCompatibleWithFont($font) === FALSE) {
         awImage::drawError('Class GDDriver: Incompatible font type (\'' . get_class($font) . '\')');
     }
     // Check which FontDriver to use
     if ($font instanceof awPHPFont) {
         $fontDriver = $this->phpFontDriver;
     } else {
         $fontDriver = $this->fileFontDriver;
     }
     if ($text->getBackground() !== NULL or $text->border->visible()) {
         list($left, $right, $top, $bottom) = $text->getPadding();
         $textWidth = $fontDriver->getTextWidth($text, $this);
         $textHeight = $fontDriver->getTextHeight($text, $this);
         $x1 = floor($point->x - $left);
         $y1 = floor($point->y - $top);
         $x2 = $x1 + $textWidth + $left + $right;
         $y2 = $y1 + $textHeight + $top + $bottom;
         $this->filledRectangle($text->getBackground(), awLine::build($x1, $y1, $x2, $y2));
         $text->border->rectangle($this, new awPoint($x1 - 1, $y1 - 1), new awPoint($x2 + 1, $y2 + 1));
     }
     $fontDriver->string($this, $text, $point, $width);
 }
Exemplo n.º 3
0
 /**
  * Draw a string
  *
  * @var awText $text Text to print
  * @param awPoint $point Draw the text at this point
  * @param int $width Text max width
  */
 public function string(awText $text, awPoint $point, $width = NULL)
 {
     $font = $text->getFont();
     // Can we deal with that font?
     if ($this->isCompatibleWithFont($font) === FALSE) {
         awImage::drawError('Class MingDriver: Incompatible font type (\'' . get_class($font) . '\')');
     }
     // Ming can only work with awFileFont objects for now
     // (i.e. awFDBFont, or awTuffy et al.)
     $fontDriver = $this->fileFontDriver;
     if ($text->getBackground() !== NULL or $text->border->visible()) {
         list($left, $right, $top, $bottom) = $text->getPadding();
         $textWidth = $fontDriver->getTextWidth($text, $this);
         $textHeight = $fontDriver->getTextHeight($text, $this);
         $x1 = floor($point->x - $left);
         $y1 = floor($point->y - $top);
         $x2 = $x1 + $textWidth + $left + $right;
         $y2 = $y1 + $textHeight + $top + $bottom;
         $this->filledRectangle($text->getBackground(), awLine::build($x1, $y1, $x2, $y2));
         $text->border->rectangle($this, new awPoint($x1 - 1, $y1 - 1), new awPoint($x2 + 1, $y2 + 1));
     }
     $fontDriver->string($this, $text, $point, $width);
 }