Closed JaimeIvanCervantes closed 7 years ago
In my application svgren renders the tiger.svg without problems:
(under windows with VisualStudio 2015)
I also don't see problems with tiger.svg, at least I tried recently under Windows and under Linux. @JaimeIvanCervantes on which OS are you trying?
I got a different tiger.svg from wikipedia which causes an assertion in svgren:
See attached tiger.svg image tiger.zip
Hm, interesting, let me try...
Ok, it uses Cubuc_Smooth_Rel elements in some path which is not implemented in svgren. I need to implement it.
It is not urgent to me but since it is a standard file on wikipmedia it would be better not to have an assertion ... https://commons.wikimedia.org/wiki/File:Ghostscript_Tiger.svg
svgren is not a complete support of the SVG standard yet, as the standard is quite big, so I implement features on demand. So thank you for finding missing stuff and providing sample SVGs for those, I add all such SVGs to the test data set. Assertions are only active in Debug configuration, in Release there are no assertions done, but I checked that tiger.svg in Relese mode, it looks quite distorted :)
In release mode I got this result:
Yep, it's quite distorted because of those missing path steps. I'm trying to fix it now.
Interesting is that the new tiger.svg from mediawiki looks identical but the file is about 30% smaller than your test tiger.svg
@saeitsystems obviously, it is because in my tiger.svg version smooth curve steps are converted to non-smooth ones, which are basically identical, only that smooth ones are shorter in writing. You can see more about smooth/non-smooth cubic curve path steps here https://www.w3.org/TR/SVG/paths.html#PathDataCubicBezierCommands
@igagis that looks quite complicated .... I think your library is already doing a very good job! Are there any favorite SVG editors you would recomend? I use AffinityDesigner on Windows or Mac. I tried Inkscape - I didn't like it because it is slow, the GUI is complicated and not standard windows and there is no UHD support.
Well, I'm not drawing much SVGs on my own, but when I need to check something or edit some SVG I use Inkscape. Because I mainly use Linux envirnoment, it is easy to install it there and it is quite sufficient for small SVG tweaks. I did not search for better editors, so, no idea what else is available.
I am using macOS Sierra with clang-802.0.42
and cairo 1.14.10
(using Homebrew), and I'm saving the results to png with the changes on my PR: https://github.com/igagis/svgren/pull/17
camera.svg
and other svgs were rendered correctly, it's only tiger.svg
that doesn't work. Hmm maybe it's something on my side, I'll keep investigating.
Ok, I think I have also seen some strange results on MacOS, but not that big as your tiger.svg. I will try to reproduce on MacOS.
I reproduced the problem with tiger.svg on MacOS, same as @JaimeIvanCervantes observes, investigating...
For some reason, on MacOS the std lib works differently than on other systems. The problem which causes the tiger.svg bug is that on MacOS the following assertion fails:
std::istringstream s("0c");
float d;
s >> d;
assert(!s.fail())
any idea how to workaround this?
I am reproducing the failed assertion:
#include <iostream>
#include <sstream>
#include <assert.h>
using namespace std;
int main() {
std::istringstream s("0c");
float d;
s >> d;
cout<<"d="<<d<<endl;
if (s.fail()) {
cout<<"Error"<<endl;
}
assert(!s.fail());
return 0;
}
And here's the output:
d=0
Error
Assertion failed: (!s.fail()), function main, file istreamstringError.cpp, line 18.
Abort trap: 6
Thinking about best way to get around it.
I think the c
next to the 0
is causing the failure. When I use std::istringstream s("0")
I don't get any errors.
Sure, but the problem is that exactly this "0c" is a valid part of SVG document which is to be parsed as number 0 and 'c' should be ignored. I'm now implementing some workaround for this.
@JaimeIvanCervantes Ok, the problem was actually in svgdom. I made a workaround. The svgdom version 0.2.36 is coming soon, here is the travis build: https://travis-ci.org/igagis/svgdom/builds when it is done, you can upgrade svgdom via Homebrew.
Excellent thanks for the quick fix! I actually have my own cmake file with svgdom and svgren dependencies, so I just pulled your changes and it works like a charm, tiger.svg
is rendering correctly now ;)
There is still other issue with Wikipedia tiger.svg, so reopening this bug for now, though the fix will come soon.
@saeitsystems Ok, new packages released to nuget: svgdom version 0.2.40 svgren version 0.4.20 please try and close the bug.
The Tiger from wikimedia renders fine now
It seems, I can't close the bug because I didn't open ist
Good, and Jaime also reported that he had no problems on MacOS now. So, closing the bug. Thank you!
Hello, I was able to render
camera.svg
and other 3 simple svgs correctly using the example ontests/render/main.cpp
buttiger.svg
is failing to render properly:Here's my result when rendering the file
camera.svg
:And here's my result when rendering the file
tiger.svg
:I use the exact same code for both, the only thing that I changed was the name of the file. I wonder if this is just happening to me, or if you also are seeing this issue too?