Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text does not render #318

Closed
centDejan opened this issue May 12, 2017 · 4 comments
Closed

Text does not render #318

centDejan opened this issue May 12, 2017 · 4 comments
Labels

Comments

@centDejan
Copy link

I have created SVG document with the FacbricJS (please find file attached).
However when I would like to render it, it does not render texts inside the file.
Text is shown if file is opened with Inkscape or any other SVG editor...

		var svgText = System.IO.File.ReadAllText("f:\\temp\\s1.svg");
		var svg = Svg.SvgDocument.FromSvg<Svg.SvgDocument>(svgText);
		var bmp = svg.Draw();
		pictureBox1.Image = bmp;

It there any workaround here?
Would appreciate quick response.

s1.zip

@smallBlacks
Copy link

i have no idea,please tell me

@haykpetros
Copy link
Contributor

Hi @centDejan,

If you look closer to your tspan elements you will notice that style attribute contains fill-rule CSS declaration that has no value. So that is causing parser to fail and not to render rest of your document. Here is an example from your document:

<tspan x="-62.26" y="10.08" style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: ; opacity: 1;">T</tspan>

So if you either remove fill-rule declaration completely or add any value to it, for example nonzero it will render just fine. Here is example that will render:

<tspan x="-62.26" y="10.08" style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;">T</tspan>

Attached is updated document that will work for you.

Now what is related to the library itself problem is with public StyleSheet Parse(string css) method in External\ExCSS\Parser.css (see line 64) that is not handling this situation properly, because generally speaking this is a properly formed CSS. So that causes exception and prevents document from rendering rest of the document, but actually it should assume a default value for the declaration when no value is specified.

I am not an expert with parsers, but hopefully someone who is will pick form here and address this very common problem.

Thanks

s1 - FIXED.zip

@centDejan
Copy link
Author

centDejan commented Aug 12, 2017 via email

@haykpetros
Copy link
Contributor

Hi @centDejan,

Happy to help you and contribute to this great library!

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants