-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Set SVG viewBox size from canvas width and height without factoring by devicePixelDensity #411
Conversation
This checks out. Please merge. |
This works for me as well, will it be merged? |
I need this PR to be merged and pushed to NPM as well. |
We'd need that fix released too. What's blocking it? |
+1 |
Funny 😂
@szimek can this be merged soon? |
@UziTech Would you have time to take a look at it? If not, I'll take a look at it myself next weekend. |
I can look at it later this week I'll be gone the next few days with limited access to internet. |
@szimek I think this should be merged. The viewBox is unitless so devicePixelRatio should not be considered. |
Thank you very much, it is working. |
There is currently an issue in the export of SVGs that causes data to be truncated off the right-hand and bottom.
The problem lies in the fact that stroke data is being recorded in terms of the overall size of the canvas and then the size of the viewBox is being reduced afterwards. It's not necessary to reduce the viewBox's size because the viewBox's width and height are unitless and only meaningful in relation to the stroke data. Reducing the maxX of the viewBox from 1000 to 500, for example, just invalidates coordinates with x > 500 because they no longer exist in the viewBox.
I think the intent of this originally must have been to preserve the dimensions of the image across devices of differing DPI, and for that we only need to adjust the width and height attributes.