W3C home > Mailing lists > Public > www-svg@w3.org > May 2014

Determining the Viewport for an SVG Element

From: Gavin Kistner <phrogz@me.com>
Date: Fri, 16 May 2014 16:28:12 -0600
Message-id: <5298326C-7B3B-41EA-8EE6-CE9279F81674@me.com>
To: www-svg <www-svg@w3.org>
In order to solve my desire to have text use the same font size[1] regardless of zooming (via the viewBox), I needed to determine the size of the viewport for the root <svg> element [2].

Given that the renderer needs to calculate this viewport anyhow, I would have thought that it would be exposed via some interface. As far as I can tell, it is not (either in specifications or practice). Am I missing something? Is there supposed to be a method/property that returns the viewport size of the contents?

The amount of code in [2] below is far more than I would like, and even then it requires knowledge of the outer dimensions of the SVG element (something that does not currently work in Firefox [3]). If there does not already exist a specification designed to grant this information directly, I would like to propose that one should be added.

(Independent of all this, Iím also interested: have there been any discussions of scale/zoom independent font sizes, similar in desire to vector-effect:non-scaling-stroke?)

[1] http://stackoverflow.com/questions/23645150/maintain-same-font-size-text-regardless-of-viewbox-zooming
[2] http://stackoverflow.com/questions/23664967/determining-the-svg-viewport-in-global-root-coordinates
[3] https://bugzilla.mozilla.org/show_bug.cgi?id=530985
Received on Friday, 16 May 2014 22:28:42 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:54:53 UTC