Skip to content

Commit

Permalink
fix point read from empty path (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
yonilevy authored Feb 12, 2020
1 parent 60bf6ea commit c89d831
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions SVGEngine.mm
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,11 @@ CGPathRef CGPathFromSVGPathString(NSString *svgString) {
}

for(NSUInteger i = 0; i < _operands.size(); i += 2) {
CGPoint currentPoint = CGPathGetCurrentPoint(_path);
CGFloat x = _operands[i+0] + (_cmd == 'm' ? currentPoint.x : 0);
CGFloat y = _operands[i+1] + (_cmd == 'm' ? currentPoint.y : 0);
CGPoint currentPoint = (_cmd == 'm' && !CGPathIsEmpty(_path))
? CGPathGetCurrentPoint(_path)
: CGPointZero;
CGFloat x = _operands[i+0] + currentPoint.x;
CGFloat y = _operands[i+1] + currentPoint.y;

if(i == 0)
CGPathMoveToPoint(_path, NULL, x, y);
Expand Down

0 comments on commit c89d831

Please sign in to comment.