From 3637a35af4ae877ca35410c19ca0285118c1a310 Mon Sep 17 00:00:00 2001 From: Baptiste Pillot Date: Mon, 21 Oct 2019 16:53:06 +0200 Subject: [PATCH] FIX SVGPath elliptical arc with rx/ry=0 + z should return to initial point (cherry picked from commit b00ecd6be852c95e699d0396f6ed4b2b54ad1e41) --- tcpdf.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tcpdf.php b/tcpdf.php index 0ee30bc..a4a059e 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -23406,7 +23406,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: */ protected function SVGPath($d, $style='') { if ($this->state != 2) { - return; + return; } // set fill/stroke style $op = TCPDF_STATIC::getPathPaintOperator($style, ''); @@ -23426,6 +23426,8 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: $xmax = 0; $ymin = 2147483647; $ymax = 0; + $xinitial = 0; + $yinitial = 0; $relcoord = false; $minlen = (0.01 / $this->k); // minimum acceptable length (3 point) $firstcmd = true; // used to print first point @@ -23470,6 +23472,8 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: if ($ck == 1) { $this->_outPoint($x, $y); $firstcmd = false; + $xinitial = $x; + $yinitial = $y; } else { $this->_outLine($x, $y); } @@ -23657,8 +23661,8 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: if ((($ck + 1) % 7) == 0) { $x0 = $x; $y0 = $y; - $rx = abs($params[($ck - 6)]); - $ry = abs($params[($ck - 5)]); + $rx = max(abs($params[($ck - 6)]), .000000001); + $ry = max(abs($params[($ck - 5)]), .000000001); $ang = -$rawparams[($ck - 4)]; $angle = deg2rad($ang); $fa = $rawparams[($ck - 3)]; // large-arc-flag @@ -23745,6 +23749,8 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: } case 'Z': { $this->_out('h'); + $x = $x0 = $xinitial; + $y = $y0 = $yinitial; break; } }