Skip to content

Access to the Units of the "width" and "height" property of a SVG Document #148

@Gleethos

Description

@Gleethos

Hello and thank you so much for your great work! :)
This library is a foundational tool which contributes tremendous value for the ecosystem.
Your time is greatly appreciated!

Our Problem

We are using jsvg to render our SVG icons into swing components.
And we have the problem that our UI/UX developer has very specific requirements when it comes
to the exact scaling behavior. More specifically, we need to define if an SVG fills out a component
by looking at the dimension units of an SVG.

Let's take 2 empty SVGs for example:

<?xml version="1.0" encoding="iso-8859-1"?>
<svg fill="#000000" version="1.1"  width="100%" height="100%" viewBox="150 0 300 600" xml:space="preserve">
</svg>
<?xml version="1.0" encoding="iso-8859-1"?>
<svg fill="#000000" version="1.1"  width="170px" height="100px" viewBox="150 0 300 600" xml:space="preserve">
</svg>

So when loading the first document, we want to fill our component entirely...
But in for the second svg, we want to scale the svg to have the exact width and height, instead
of making the width and height dependent on the component dimensions...

And so the question we have is:

How can we access the unit of the document size in jsvg?

More specifically, there is SVGDocument.size(), which does give us the width and height as floats...
But the information about the unit is lost.

Is there a way to access it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions