Pixplicity / sharp

Scalable vector graphics for Android
Apache License 2.0
1.03k stars 117 forks source link

Please add support svg with layers. #25

Closed AraBadalyan closed 7 years ago

AraBadalyan commented 8 years ago

First of all thank you for this good library. The problem is that library won't load svg with layers for exaqmple "<g id="Layer_1"> <circle id="test2" class="st0" cx="198.9" cy="200.9" r="42.9"/> It will be great if I can detect layers with path programmatically like some ios libraries. Thanks.

filipc commented 8 years ago

Can you attach example of svg that is not recognized?

AraBadalyan commented 8 years ago

Yes of course

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     viewBox="0 0 400 400" style="enable-background:new 0 0 400 400;" xml:space="preserve">
<style type="text/css">
    .st0{fill:#FFFFFF;stroke:#000000;stroke-width:4;stroke-miterlimit:10;}
</style>
<g id="Layer_1">
    <rect id="test0" x="26.4" y="28.3" class="st0" width="345" height="345"/>
</g>
<g id="Layer_2">
    <rect id="test1" x="98.3" y="100.3" class="st0" width="201.1" height="201.1"/>
</g>
<g id="Layer_3">
    <circle id="test2" class="st0" cx="198.9" cy="200.9" r="42.9"/>
</g>
<g id="Layer_4">
    <circle id="test3" class="st0" cx="68.8" cy="69.3" r="30.1"/>
</g>
</svg>
pflammertsma commented 8 years ago

Sharp does not offer support for CSS, so this might describe part of your problem. If you migrate the class styles into a style="..." attribute, does this give the desired effect?

If not, can you elaborate on what you mean with "[Sharp] won't load svg with layers"?