paulpatarinski / Xamarin.Forms.Plugins

Xamarin Forms Plugins
http://paulpatarinski.github.io/Xamarin.Forms.Plugins
MIT License
276 stars 141 forks source link

SVG.Forms.Plugin.Android doesn't work on standard SVG files #26

Open Emasoft opened 9 years ago

Emasoft commented 9 years ago

SVG.Forms.Plugin.Android doesn't display my svg assets. It just crashes everytime. I've made those with Inkscape, and saved as "plain svg".

You can download an .svg test file of my buttons from here: http://goo.gl/m7TbmM

This is a preview of some of my SVG buttons:

Emasoft commented 9 years ago

Any update on this? And what about the iOS version? Does it support svg?

paulpatarinski commented 9 years ago

Hey @Emasoft, sorry been meaning to write up a response.

As far as getting your svgs working : they contain some shapes that are not supported by XamSvg (the library I am using for Android). I am working on adding much better support for SVGs for both iOS and Android but in the meantime I recommend you open the source of your svg and try to simplify it as much as possible starting with just a single Path and building up from there to help you identify what shapes you are using that are not supported.

Example :

Right now your svg has 925 lines a mix of a lot of different tags : <path <text <defs <filter <linearGradient

Take just :

<path d="M 557.07454,280.35735 736.39859,280.35735 C 756.74069,280.35735 773.11719,265.96425 773.11719,248.08582 L 773.11719,198.55278 C 773.11719,180.67436 756.74069,166.28126 736.39859,166.28126 L 557.07454,166.28126 C 536.73238,166.28126 520.35583,180.67436 520.35583,198.55278 L 520.35583,248.08582 C 520.35583,265.96425 536.73238,280.35735 557.07454,280.35735 z" id="path3164" style="color:#000000;fill:none;stroke:#000000;stroke-width:7;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;filter:url(#filter5367);enable-background:accumulate" />

Remove the Style attribute and check what that renders and build it up from there.

While I know that's kind of tedious that's the temporary workaround while I get a better implementation working.

Also here is an issue regarding iOS : https://github.com/paulpatarinski/Xamarin.Forms.Plugins/issues/17

I will post an update there.

Paul

Emasoft commented 9 years ago

@paulpatarinski Thank you for your answer. Unfortunately I have a lots of svg assets, and having to fix manually all of them is something that would take too much time and I'm already behind schedule for my projects. Also it would be useless, because I (and the artists I work with) will always make many last minute changes to the graphic assets in Inkscape, so we need to be able to just quickly load-modify-save the assets from Inkscape without having to manually re-edit all of them each time we change a detail or a color. For production reasons I think that manually modifying the graphic files would never be an option. We need to be able to load standard svg files exactly the same way we load standard png files. We choose svg as a standard vector format for our crossplatform applications (instead of .ai or .ps, or .wmf, and any other proprietary format) exactly because it's a widespread standard and open format. I know that your support for svg is still worked on, and I will wait for you to complete the importer. We are using bitmap placeholders for now, while we are still developing the app, so we can wait until everything else is in place to add the svg assets.

paulpatarinski commented 9 years ago

What you are saying makes total sense. I am a big fan of SVGs and was very disappointed at last Evolve when the Forms team told me that they don't have plans on adding support, since NO ONE HAS ASKED FOR IT, so I took it upon myself to add support. It is not super difficult, but it is pretty tedious and requires a lot of research (finding existing libraries and trying to port them) and it's not my full time job, so I mostly work on it nights and weekends. I will keep you posted on the progress, but my ultimate goal is what you described.

Emasoft commented 9 years ago

@paulpatarinski I really appreciate what you are doing. I really cannot understand how the Xamarin developers could have forgotten to support this important graphic format in Xamarin.Forms.

paulpatarinski commented 9 years ago

@Emasoft wanted to give you a quick update. Got a little further on rendering the buttons

image

As you can see the shapes look correct now it is a matter of getting the Text to be properly formatted and the gradients to work. Will keep you posted

paulpatarinski commented 9 years ago

@Emasoft getting the gradients working is a lot of additional work. For now I will close this issue I have #27 open to address the gradients. Other then Gradients most svgs should be rendered correctly

Emasoft commented 9 years ago

Ok for implementing gradients. But why did you close this issue? SVG files are still not displayed correctly, so this is still an issue. You should close this issue only when the library will be fully SVG 1.1 compliant. Otherwise anybody that discover this issue loading some svg file will report here opening a new issue. Please leave this open to avoid a proliferation of multiple issues for this.

paulpatarinski commented 9 years ago

Valid point. Reopened.