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

svg is drawn smaller than actual size #39

Open
9tontruck opened this issue Apr 2, 2014 · 4 comments
Open

svg is drawn smaller than actual size #39

9tontruck opened this issue Apr 2, 2014 · 4 comments

Comments

@9tontruck
Copy link

SVG object is drawn about 25% smaller than the actual size.

see this photo please: http://imageshack.com/a/img203/5676/gqrf.jpg

The first line in the photo is drawn by my own SVG parser.
The second line is drawn by AS3SVGRenderer.

Both parsers used to draw in the same size but this problem happened after I updated AS3SVGRenderer from one-year old version to the newest version.

All I wrote is
var svg:SVG = new SVG() //Flex.SVG
svg.source = getSVGText();

Is there anything I am missing?

@9tontruck
Copy link
Author

Figured out having viewbox parameter in tag makes size problem.

@mattlohkamp
Copy link

this is huge - even if the artwork is 120x120, the artboard is 120x120, everything is 120x120 - the image drawn in flash might still end up being scaled wrong. removing that viewbox attr fixes it.

this is still very much a big bug.

@lucaslorentz
Copy link
Owner

I am comparing the library result with chrome.
And both size is precisely equal when you have a viewbox and the svg width and height are set as pixels.

But if I change svg width and height to pt, in, cm, or any unit that must be converted using dpi, there is a slight size difference between the AS3SVGRenderer and chrome.

That conversion is coded on method getUserUnit, at this file:
https://github.com/LucasLorentz/AS3SVGRenderer/blob/master/SVGRenderer/src/com/lorentz/SVG/utils/SVGUtil.as

You can see that the conversion from "in" to "pixels" (user unit) is a multiplication by "90", that, means that this library considers 90 dpi (dots per inch). Which is the same of Inkscape. But each renderer choose a different DPI to render, maybe that's the difference that you are seeing.

Take a look at those links:
http://stackoverflow.com/questions/1346922/svg-and-dpi-absolute-units-and-user-units-inkscape-vs-firefox-vs-imagemagick
http://www.w3.org/TR/SVG/coords.html#Units

Can any of you confirm that this is what is causing the difference on size?
If that's the problem, I can provide a property to configure the DPI the library should use, that way you can customize it to fit your needs.

If that isn't the problem, can you provide me an svg to reproduce the problem?

About the differences between old version of AS3SVGRenderer and the current version, I believe the version you were using don't support ViewBox and ViewPort correctly, so it don't re-scale the svg.

@mattlohkamp
Copy link

github won't let me attach svgs, so here are a couple links -

http://junk.mattlohkamp.com/2in1.svg
http://junk.mattlohkamp.com/tablet.svg

not sure what version of the library this was using, I wanna say I grabbed it a couple months ago?

it was happening intermittently too, which was one of the weirdest parts - sometimes they'd scale correctly, sometimes they wouldn't. sorry, I know this isn't much help. :[

I'll see if I can dig up the old build of my project that was showing the issue.

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

No branches or pull requests

3 participants