Permalink
Browse files

* #16833: patch for newlines in SVG addText()

* #16925: Angled text improperly displayed in SVG (Note: a first fix; might need further testing/adjustments)


git-svn-id: https://svn.php.net/repository/pear/packages/Image_Canvas/trunk@292672 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent b77258e commit 4f2f7a75a5feb70470096a2f70bdc9f4f07ff4be @neufeind neufeind committed Dec 26, 2009
Showing with 4 additions and 4 deletions.
  1. +4 −4 Image/Canvas/SVG.php
View
8 Image/Canvas/SVG.php
@@ -694,7 +694,7 @@ function pieslice($params)
function textWidth($text)
{
if ((isset($this->_font['vertical'])) && ($this->_font['vertical'])) {
- return $this->_font['size'];
+ return $this->_font['size'] * count(explode("\n",$text));
} else {
return round($this->_font['size'] * 0.7 * strlen($text));
}
@@ -712,7 +712,7 @@ function textHeight($text)
if ((isset($this->_font['vertical'])) && ($this->_font['vertical'])) {
return round($this->_font['size'] * 0.7 * strlen($text));
} else {
- return $this->_font['size'];
+ return $this->_font['size'] * count(explode("\n",$text));
}
}
@@ -793,7 +793,7 @@ function addText($params)
'x="0" ' .
'y="0" ' .
(isset($this->_font['angle']) && ($this->_font['angle'] > 0) ?
- 'transform="rotate(' . (($this->_font['angle'] + 180) % 360) . ')" ' :
+ 'transform="rotate(' . (((-1) * $this->_font['angle']) % 360) . ')" ' :
''
) .
'style="' .
@@ -806,7 +806,7 @@ function addText($params)
) . ';' . $align . '"' .
($attrs ? ' ' . $attrs : '') .
'>' .
- htmlspecialchars($text) .
+ ('<tspan x="0" dy="0em">'. implode('</tspan><tspan x="0" dy="1em">', explode("\n",htmlspecialchars($text))).'</tspan>') .
'</text>' . "\n" .
$this->_indent . '</g>',
$params

0 comments on commit 4f2f7a7

Please sign in to comment.