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

Minimal viewBox for SVG exports #69

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

fkettelhoit
Copy link

When I export to svg, I usually want the file to have the same dimensions as the content, without any empty space around it. Right now this is only possible by manually editing the .svg output and adding a viewBox attribute, which requires calculating the minimal x and y values as well as the width and height of the content while taking into account the line thickness. The whole process can be quite time-consuming and error-prone for larger files.

The PR automatically calculates and saves the viewBox and tries to make sure that the resulting svg fits into these bounds. In the case of round or beveled line joins this is quite easy, but in the case of miter line joins (which could theoretically overshoot the angle point by quite a large amount in the case of sharp angles) an offset equivalent to the line thickness is used (which should give an acceptable result in most cases).

@Ledmington
Copy link

Any updates on this?

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

Successfully merging this pull request may close these issues.

2 participants