Thursday, January 30, 2014

Announcing SVGgh - A library for rendering SVG in iOS

I've spent the last several days putting the finishing touches on open-sourcing my code for rendering SVG: SVGgh. This is the first time I've put anything public up on GitHub, and I hope my fellow developers can find it and make use of it. It's under MIT license, so I expect there will be no problems using it in your projects or extending it for your own uses, or even just as a tutorial for understanding Core Graphics or Core Text.

Here are a few highlights:

  1. SVGDocumentView - A view to replace UIImageView with a nice, crisp, re-scaleable SVG image. Configurable from a Storyboard or nib.
  2. GHButton - A UIControl button which can draw a nice chrome appearance, and have an embedded SVG icon.
  3. SVGRenderer - A class capable of rendering an SVG into a CGContextRef, so if you wanted to convert an SVG to a PDF or some bitmap format, that would be doable. 
  1. It doesn't do everything in the SVG spec. No animations, SVG Fonts, filter effects.
  2. It has code that needs some bug fixing. Just today, I realized my gradients weren't working properly with entities that had a transform attribute set.  But in general, I've been using this code for over a year in my own apps and it's been fine. 
  3. It's not necessarily the best code for making an editor.
I've cleaned the code like crazy the last couple days. Renaming classes, cleaning up parameters, adding Doxygen style header comments, and moving code around to have better organization. It should be in good shape for others to just pop in and use.