-
Notifications
You must be signed in to change notification settings - Fork 560
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
SVGView ScaleAspectFit broken for non square SVG's #111
Comments
Sorry for late response. A developer who was assigned to this issue is too busy on another project, so I'm reassigning this ticket. Could you please attach an SVG file with incorrect bounds calculation? |
Absolutely. This svg is 247 x 344 but the rect returned from it's bounds is ~ 312 x 343, thus throwing off the scaling calculations. If you hardcode the width and height to be 247 x 344 in the scaling algorithm, it scales properly. |
Thanks! Reproduced this issue. |
Any word on when this will be fixed? I've run into it in one of my projects. I may have time next week to investigate myself if someone can point me in the right direction... |
Hi Morgan! Thanks for your readiness to help! However we just fixed this issue in the master. So you can try the latest version using:
|
I'll give it a test, thanks! |
Svg's rendered in an SVGView using ScaleAspectFit are not scaled properly if the SVG is not approximately a square.
It looks like the svgNode.bounds() is returning a rect that is larger than the svg width and height, which then throws off the scaleAspectFit calculations. For example, an svg with a width of 320 and height of 700 (a tall rectangle) might have the svgNode.bounds() return a rect that is closer to a width of 700 and a height of 700 (a Square).
The algorithm seems to be correct as I commented out the two lines in the render method that calculates the svgWidth and svgHeight based on the node bounds, and replaced the values with the actual width and height of my test svg's and everything worked properly.
The text was updated successfully, but these errors were encountered: