SVG: Correctly handle relative "moveto" commands.

Closes #1101
This commit is contained in:
Jürg Lehni 2016-07-11 19:48:17 +02:00
parent 4df2dfb343
commit 73fc111b50

View file

@ -99,8 +99,10 @@ var PathItem = Item.extend(/** @lends PathItem# */{
coords = part.match(/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g);
var length = coords && coords.length;
relative = command === lower;
// Fix issues with z in the middle of SVG path data, not followed by
// a m command, see #413:
if (previous === 'z' && !/[mz]/.test(lower))
this.moveTo(current = start);
this.moveTo(current);
switch (lower) {
case 'm':
case 'l':
@ -170,6 +172,8 @@ var PathItem = Item.extend(/** @lends PathItem# */{
// Merge first and last segment with Numerical.EPSILON tolerance
// to address imprecisions in relative SVG data.
this.closePath(/*#=*/Numerical.EPSILON);
// Correctly handle relative m commands, see #1101:
current = start;
break;
}
previous = lower;