commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / vendor / phenx / php-svg-lib / src / Svg / Tag / Text.php
1 <?php
2 /**
3 * @package php-svg-lib
4 * @link http://github.com/PhenX/php-svg-lib
5 * @author Fabien Ménager <fabien.menager@gmail.com>
6 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
7 */
8
9 namespace Svg\Tag;
10
11 class Text extends Shape
12 {
13 protected $x = 0;
14 protected $y = 0;
15 protected $text = "";
16
17 public function start($attribs)
18 {
19 $document = $this->document;
20 $height = $this->document->getHeight();
21 $this->y = $height;
22
23 if (isset($attribs['x'])) {
24 $this->x = $attribs['x'];
25 }
26 if (isset($attribs['y'])) {
27 $this->y = $height - $attribs['y'];
28 }
29
30 $document->getSurface()->transform(1, 0, 0, -1, 0, $height);
31 }
32
33 public function end()
34 {
35 $surface = $this->document->getSurface();
36 $x = $this->x;
37 $y = $this->y;
38
39 if ($surface->getStyle()->textAnchor == "middle") {
40 $width = $surface->measureText($this->text);
41 $x -= $width / 2;
42 }
43
44 $surface->fillText($this->text, $x, $y);
45 }
46
47 protected function after()
48 {
49 $this->document->getSurface()->restore();
50 }
51
52 public function appendText($text)
53 {
54 $this->text .= $text;
55 }
56 }