Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

* #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...
commit 4f2f7a75a5feb70470096a2f70bdc9f4f07ff4be 1 parent b77258e
Stefan Neufeind neufeind authored

Showing 1 changed file with 4 additions and 4 deletions. Show diff stats Hide diff stats

  1. +4 4 Image/Canvas/SVG.php
8 Image/Canvas/SVG.php
@@ -694,7 +694,7 @@ function pieslice($params)
694 694 function textWidth($text)
695 695 {
696 696 if ((isset($this->_font['vertical'])) && ($this->_font['vertical'])) {
697   - return $this->_font['size'];
  697 + return $this->_font['size'] * count(explode("\n",$text));
698 698 } else {
699 699 return round($this->_font['size'] * 0.7 * strlen($text));
700 700 }
@@ -712,7 +712,7 @@ function textHeight($text)
712 712 if ((isset($this->_font['vertical'])) && ($this->_font['vertical'])) {
713 713 return round($this->_font['size'] * 0.7 * strlen($text));
714 714 } else {
715   - return $this->_font['size'];
  715 + return $this->_font['size'] * count(explode("\n",$text));
716 716 }
717 717 }
718 718
@@ -793,7 +793,7 @@ function addText($params)
793 793 'x="0" ' .
794 794 'y="0" ' .
795 795 (isset($this->_font['angle']) && ($this->_font['angle'] > 0) ?
796   - 'transform="rotate(' . (($this->_font['angle'] + 180) % 360) . ')" ' :
  796 + 'transform="rotate(' . (((-1) * $this->_font['angle']) % 360) . ')" ' :
797 797 ''
798 798 ) .
799 799 'style="' .
@@ -806,7 +806,7 @@ function addText($params)
806 806 ) . ';' . $align . '"' .
807 807 ($attrs ? ' ' . $attrs : '') .
808 808 '>' .
809   - htmlspecialchars($text) .
  809 + ('<tspan x="0" dy="0em">'. implode('</tspan><tspan x="0" dy="1em">', explode("\n",htmlspecialchars($text))).'</tspan>') .
810 810 '</text>' . "\n" .
811 811 $this->_indent . '</g>',
812 812 $params

0 comments on commit 4f2f7a7

Please sign in to comment.
Something went wrong with that request. Please try again.