Skip to content

Commit

Permalink
Merge pull request #1 from Orken/Orken-patch-1
Browse files Browse the repository at this point in the history
Fix Text-anchor=end
  • Loading branch information
Orken committed Feb 17, 2016
2 parents e30f8e9 + 07c8097 commit 8db6350
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Svg/Tag/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* @package php-svg-lib
* @link http://github.com/PhenX/php-svg-lib
* @author Fabien Ménager <[email protected]>
* @author Fabien Ménager <[email protected]>
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
*/

Expand Down Expand Up @@ -36,10 +36,14 @@ public function end()
$x = $this->x;
$y = $this->y;

$width = $surface->measureText($this->text);

if ($surface->getStyle()->textAnchor == "middle") {
$width = $surface->measureText($this->getText());
$x -= $width / 2;
}
if ($surface->getStyle()->textAnchor == "end") {
$x -= $width;
}

$surface->fillText($this->getText(), $x, $y);
}
Expand All @@ -58,4 +62,4 @@ public function getText()
{
return trim($this->text);
}
}
}

0 comments on commit 8db6350

Please sign in to comment.