memononen / nanosvg

Simple stupid SVG parser
zlib License
1.69k stars 357 forks source link

Bug: pathFlag is never set #160

Open scippie75 opened 5 years ago

scippie75 commented 5 years ago

I am trying to add functionality to parse the <desc> element within a <path> element.

This made me find this bug: In nsvg__startElement, the pathFlag is tested to prevent handling nested paths. But this flag is never set anywhere in the code, it is only being reset in the nsvg__endElement function. I want to use the pathFlag to know whether the <desc> element is inside the path element.

I added p->pathFlag = 1; after this test.

EDIT: I just finished the implementation, it works on description on any shape, not only paths (so the pathFlag isn't used). If you are interested, I can share the code.

Another EDIT: I noticed that the contents of the SVG tags are html-encoded. The strings need to be converted back to a cstring or an UTF-8 string. I am now using a small decoding c/h api for it, but is this maybe something that should be added to nanosvg itself? (would be something like 400 lines of extra code, mostly because of the lookup table which could of course be compacted in less lines)