* @package cleversvg * @subpackage elements */ class csText extends csBaseShape { protected $text_content = NULL, $xml_node_name = 'text'; /** * Class constructor * * @param mixed $x * @param mixed $y * @param mixed $content */ public function __construct($x=null, $y=null, $content=null, $attrs=array()) { $this->setX($x); $this->setY($y); $this->setContent($content); $this->attributes = array_merge($attrs, $this->attributes); } /** * Computes DOMXML Node * * @param boolean $embedded Is SVG element embedded ? * @return DOMElement */ public function compile($embedded=false) { $node = parent::compile($embedded); $dom = $this->getDomDocument(); if (!is_null($this->text_content)) { $content_node = $dom->createTextNode($this->text_content); $node->appendChild($content_node); } return $node; } /** * Sets the text content * * @param string $content */ public function setContent($content) { if (!is_null($content)) { $this->text_content = $content; } } /** * Sets the font family * * @param mixed $font_family * @link http://www.w3.org/TR/SVG11/text.html#FontSizeProperty */ public function setFontFamily($font_family) { $this->setAttribute('font-family', $font_family); } /** * Sets the font size * * @param mixed $font_size * @link http://www.w3.org/TR/SVG11/text.html#FontSizeProperty */ public function setFontSize($font_size) { $this->setAttribute('font-size', $font_size); } /** * Sets the font size-adjust * * @param mixed $font_size_adjust * @link http://www.w3.org/TR/SVG11/text.html#FontSizeAdjustProperty */ public function setFontSizeAdjust($font_size_adjust) { $this->setAttribute('font-size-adjust', $font_size_adjust); } /** * Sets the font stretch * * @param mixed $font_stretch * @link http://www.w3.org/TR/SVG11/text.html#FontStretchProperty */ public function setFontStretch($font_stretch) { $this->setAttribute('font-stretch', $font_stretch); } /** * Sets the font style * * @param mixed $font_style * @link http://www.w3.org/TR/SVG11/text.html#FontStyleProperty */ public function setFontStyle($font_style) { $this->setAttribute('font-style', $font_style); } /** * Sets the font variant * * @param mixed $font_variant * @link http://www.w3.org/TR/SVG11/text.html#FontVariantProperty */ public function setFontVariant($font_variant) { $this->setAttribute('font-variant', $font_variant); } /** * Sets the font weight * * @param mixed $font_weight * @link http://www.w3.org/TR/SVG11/text.html#FontWeightProperty */ public function setFontWeight($font_weight) { $this->setAttribute('font-weight', $font_weight); } /** * The start x-axis coordinate of the text * */ public function setX($x) { $this->setAttribute('x', $x); } /** * The start y-axis coordinate of the text * */ public function setY($y) { $this->setAttribute('y', $y); } }