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

Does not render .svg properly #632

Closed
GeneThomas opened this issue Jan 7, 2020 · 6 comments · Fixed by #639
Closed

Does not render .svg properly #632

GeneThomas opened this issue Jan 7, 2020 · 6 comments · Fixed by #639

Comments

@GeneThomas
Copy link

The attached Visual Studio solutions load a .svg using the library the .bmp saved does not look like the .svg when the .svg is opened in Microsoft Egde nor Google Chrome.

Example data

US Political.zip

Used Versions

3.0.84 and the lastets fro GitHub master

Projects exersixing the bug:

SvgBug - Svg 3.0.84.zip
SvgBug - Svg GitHub master 2020-01-07.zip

@wieslawsoltes
Copy link
Contributor

Looks like issue is with this element CSS style:

<text x="76.498344" y="66.684082" transform="scale(0.997651, 1.00235)" id="text776" xml:space="preserve" style="font-size:13.08702374px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:0.75;stroke-width:3pt;font-family: Nimbus Sans L,'Arial Narrow',sans-serif; -inkscape-font-specification:Nimbus Sans L Bold"><tspan x="76.498344" y="66.684082" id="tspan795" style="font-size:13.08702374px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family: Nimbus Sans L,'Arial Narrow',sans-serif;Sans L',sans-serif;-inkscape-font-specification:Nimbus Sans L Bold">Washington     </tspan></text>

This lines throws:
https://github.com/vvvv/SVG/blob/3b489404bb112727690388c49b00905cfeb61578/Source/External/ExCSS/Model/Values/TermList.cs#L76-L77

Exception thrown: 'System.ArgumentOutOfRangeException' in System.Private.CoreLib.dll
Index was out of range. Must be non-negative and less than the size of the collection.

@wieslawsoltes
Copy link
Contributor

If you replace

font-family:  Nimbus Sans L,'Arial Narrow',sans-serif;Sans L',sans-serif

to

font-family:  Nimbus Sans L,'Arial Narrow',sans-serif

it should work

US Political-fixed.zip

@GeneThomas
Copy link
Author

Thanks. It would be good if Svg.dll could handle faults the MS Edge and Google Chrome do, but I guess that is a slipery slope.

@H1Gdev
Copy link
Contributor

H1Gdev commented Jan 9, 2020

font-family: Nimbus Sans L,'Arial Narrow',sans-serif;Sans L',sans-serif;

Is font-family correct the following ?

  • Nimbus Sans L
  • Arial Narrow
  • sans-serif;Sans L
  • sans-serif

@mrbean-bremen
Copy link
Member

As @wieslawsoltes wrote, the correct part is Nimbus Sans L,'Arial Narrow',sans-serif.
The error obviously happened while writing the tag (looks like some buffer overflow), and leads to a stray apostroph, which cannot be handled by the parser.
To correct this, the parser has to detect that the opening apostroph has no closing counterpart within the tag (maybe not trivial) and disregard the invalid part.

@H1Gdev
Copy link
Contributor

H1Gdev commented Jan 10, 2020

I worry about cause because only <tspan> font-family is incorrect.
So I want to know how to specify font-family.

To correct this, the parser has to detect that the opening apostroph has no closing counterpart within the tag (maybe not trivial) and disregard the invalid part.

I think so too.

H1Gdev added a commit to H1Gdev/SVG that referenced this issue Jan 12, 2020
mrbean-bremen pushed a commit that referenced this issue Jan 12, 2020
* Fix: #632 'Does not render .svg properly' issue.
* Add tests.
* Update ReleaseNotes.md.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants