comfy/comfortable-mexican-sofa — pull request #354 by k3rni (2013-10-09 09:09:22+00:00)
Title: Handle SVG font uploads

If you keep all assets in uploaded files, you may also need SVG fonts. These aren't distinguishable from normal SVG images by extension nor mimetype. And when handed to Paperclip to create thumbnails (hey, it's an image!), it throws strange errors about not recognizing that type of file. I don't really think it's a Paperclip problem, rather it boils down to the way CMS recognizes images - by mimetype alone.

Anyway, this fixes that situation by carefully looking inside (the first 4kb of) uploaded SVG files, and trying to determine whether it's a font. To avoid memory consumption, we don't really parse the SVG, but only look for a `` tag.

To verify, comment out the added `before_post_process` line and run tests (and try uploading a SVG font via the browser), there will be errors about unrecognized file types. Unstubbing Paperclip was required - the errors don't show up until it wants to make a thumbnail.

The font included in fixture files is a very stripped-down version of [Droid Serif Regular](http://www.google.com/fonts/specimen/Droid+Serif), which is Apache-licensed.