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-native] Should a viewBox be required? #684

Open
AmeliaBR opened this issue May 7, 2019 · 1 comment
Open

[svg-native] Should a viewBox be required? #684

AmeliaBR opened this issue May 7, 2019 · 1 comment

Comments

@AmeliaBR
Copy link
Contributor

AmeliaBR commented May 7, 2019

A viewBox on the containing <svg> element gives the image an intrinsic aspect ratio & makes percentage lengths predictable (the convert to the same px values regardless of image scale), so that the graphic reliably scales up & down like an image (all parts scaling equally).

SVG in OpenType does not currently require a viewBox, but it's less of an issue there because the size & aspect ratio of each glyph is defined by other font data.

As Chris notes in #667 (comment), EPS requires a declared bounding box for similar reasons.

@svgeesus
Copy link
Contributor

svgeesus commented May 7, 2019

SVG in Opentype doesn't require viewBox but does allow it (several examples use it); if used there is the additional constraint specific to that environment:

Note: When using a viewBox attribute on the element, it is important to specify unitsPerEm for width and height values to avoid a scaling effect.

The advantage of requiring it is that implementations do not need to scan over all the coordinates used and guess what the actually used range of coordinates should be.

I remember a common utility tool, BBFig was used to run over a PS file and a) compute the minimal bounding box b) remove any showpage command, to make EPS files.

I could certainly imagine a similar tool that helps turn a random SVG file into an ESVG file. Applications exporting to ESVG would already have the info needed to export a viewBox, there is no reason for them not to do so.

There would be a disadvantage for hand authoring (unless there was tooling support) in requiring a viewBox, but I don't think that is a primary use case and it is readily realt with by linting or post-processing tools.

Overall I tend towards requiring viewBox, ideally as a MUST, if not then at least a SHOULD.

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

No branches or pull requests

2 participants