SVG Filters

I’ve finally found the motivation to begin the implementation of SVG filters in lasem. It’s still pretty rough, there’s a lot of bugs to fix and things to finish, but when I’ve tried to render icons from gnome-icon-theme, a very large subset of this theme renders fine. Here’s an example:

For now, feGaussianBlur, feOffset, feBlend, feMerge, feMergeNode, feComposite and feFlood are supported. Support the remaining filter primitive should appear soon. Fortunately, I’m able to use Caleb Moore’s librsvg code (same license) for the filter algorithms, even if I try to use cairo API when possible.

I’ve done some work on markers, fixing overflow and automatic marker orientation:

I’ve also lately worked on the robustness of lasem, by importing in the test suite a lot of the attached files in librsvg bug reports, thanks to Olav Vitters who gave me the method for an automatic extraction of attached files in bugzilla. I’ve first downloaded the result of a bugzilla query as xml, then wrote a small script which finds attachement url and retrieves them.

Here’s the script (be careful if you use it, as bugzilla will ban you if you download a large amount of data):

# coding=utf-8

import urllib2
import xml.dom
import time
import os
import sys
import codecs
import subprocess
import locale
from xml.dom.minidom import parseString

def getText (element, tag):
        nodelist = element.getElementsByTagName (tag)[0].childNodes
        rc = []
        for node in nodelist:
                if node.nodeType == node.TEXT_NODE:
        return ''.join(rc)

count = 0

file = open('librsvg.xml')
data =

dom = parseString(data)

bugs = dom.getElementsByTagName('bug')
for bug in bugs:
        bug_id = getText (bug, 'bug_id')
        attachments = bug.getElementsByTagName('attachment')
        for attachment in attachments:
                if attachment.getAttribute('ispatch') != "1":
                        attachment_id = getText (attachment, 'attachid')
                        type = getText (attachment, 'type')
                        if type == 'image/svg+xml' or type == 'image/png':
                                filename = getText (attachment, 'filename')

                                url = "" % attachment_id
                                output_filename = "librsvg/librsvg-bug%s-%s" % (bug_id, filename)
                                input_file = urllib2.urlopen( url)
                                data = ()
                                input_file.close ()

                                output_file = open(output_filename, 'w')
                                output_file.write (data)
                                output_file.close ()

                                time.sleep (5)
                                count = count + 1

print count

Leave a Reply

Your email address will not be published. Required fields are marked *