avianey / androidsvgdrawable-plugin

Gradle plugin that generates qualified, density specific PNG drawables from SVG files at build time for your Android projects.
Apache License 2.0
262 stars 29 forks source link

SVG creates all-transparent image #29

Closed schildbach closed 9 years ago

schildbach commented 9 years ago

This SVG creates just a transparent image – I'd expect a grey600 'H' and a grey600 circle around it. I cross-tested generation with batik-rasterizer.jar 1.7.1 and 1.8 – both render the SVG as expected.

FWIW, the filename is "ic_oeffi_stations_grey600_36dp-hdpi.svg".

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="72px" height="72px" viewBox="-32 -32 1088 1088">
    <!-- background -->
    <path
        d="M 512,512 m -464,0 a 464,464 0 1,0 928,0 a 464,464 0 1,0 -928,0
        M 512,512 m -368,0 a 368,368 0 1,1 736,0 a 368,368 0 1,1 -736,0"
        fill="#757575" />

    <!-- H -->
    <path d="M 370,760 v -500 m 0,240 h 280 m 0,260 v -500" style="fill:none;stroke:#757575;stroke-width:96" />
</svg>
avianey commented 9 years ago

Could you please try what is described here to have a bounding box set through inkscape : https://github.com/avianey/androidsvgdrawable-plugin#bounding-box Your SVG is missing x and y attribute values for the <svg> node...

avianey commented 9 years ago

Will unit test it when possible...

schildbach commented 9 years ago

A added x and y attributes (which should default to "0" anyway) and also tried removing the "px" from width and height, but it did not change the output.

schildbach commented 9 years ago

Actually I think you're bending the SVG spec somehow. According to the spec width and height on the SVG root element are called "viewport" (not "bounding box"), and there are no x and y parameters. What are you using them for?

schildbach commented 9 years ago

Slight correction. The spec allows for x and y in the SVG root element, but it says "Has no meaning or effect on outermost svg elements." Also: "If the attribute is not specified, the effect is as if a value of '0' were specified."

schildbach commented 9 years ago

Thanks for the quick fix! I just checked and it now works as expected.

avianey commented 9 years ago

still a little glitch in the test to fix for the oracle jdk... by the way it shows that batik does not generate exactly the same png when using oracle jdk or open jdk... but the eye wont see the difference