CGPathGetCurrentPoint: no current point emitted
robaho opened this issue · 7 comments
robaho commented
When using PocketSVG, it continually emits 'no current point'.
I believe the problem is the following code is lines 576-578 in SVGEngine.mm
CGPoint currentPoint = CGPathGetCurrentPoint(_path);
CGFloat x = _operands[i+0] + (_cmd == 'm' ? currentPoint.x : 0);
CGFloat y = _operands[i+1] + (_cmd == 'm' ? currentPoint.y : 0);
in pathDefinitionParser::appendMoveTo()
I believe the code should be changed to be:
CGPoint currentPoint = _cmd == 'm' && !CGPathIsEmpty(_path) ? CGPathGetCurrentPoint(_path) : CGPointZero;
CGFloat x = _operands[i+0] + currentPoint.x;
CGFloat y = _operands[i+1] + currentPoint.y;
which will avoid calling CGPathGetCurrentPoint() when the path is most likely empty, and wouldn't be used anyway.
arielelkin commented
Hi @robaho
Could you please provide steps to reproduce this issue?
DanielGibbsNZ commented
I'm experiencing this issue as well. I can reproduce it with the following code and SVG:
let url = Bundle.main.url(forResource: "example", withExtension: "svg")
let svgLayer = SVGLayer(contentsOf: url!)
example.svg
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg">
<path d="M25,50 C25,100 150,100 150,50 Z" />
</svg>
robaho commented
I gave the PR that fixes it. And the previous poster has given the test case. I would suggest applying the PR.
… On Aug 2, 2019, at 7:20 PM, Daniel Gibbs ***@***.***> wrote:
I'm experiencing this issue as well. I can reproduce it with the following code and SVG:
let url = Bundle.main.url(forResource: "example", withExtension: "svg")
let svgLayer = SVGLayer(contentsOf: url!)
example.svg
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg">
<path d="M25,50 C25,100 150,100 150,50 Z" />
</svg>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
robaho commented
I’m sorry, I had a PR but didn’t submit it - the code changes I show in the comment are what is needed. I will see if I can resurrect the PR.
… On Aug 7, 2019, at 6:48 PM, Fjölnir Ásgeirsson ***@***.***> wrote:
I don't see any PR originating from you @robaho <https://github.com/robaho>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#150?email_source=notifications&email_token=ABF2U4OTIWTUYMIVG5KXYWLQDNNNLA5CNFSM4GX7SXS2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD32ALOI#issuecomment-519308729>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ABF2U4P5RDXTQX4FK3JUQGDQDNNNLANCNFSM4GX7SXSQ>.
arielelkin commented
fixed via #173