Finishing Google Summer of Code

I have now merged the second phase of my Google Summer of Code project, unit support improvements, into the Inkscape trunk. Back in April when I proposed this project, I thought refactoring Inkscape’s unit support would be the easier part of the project and improving the unit support would be the more difficult part. In retrospect, the opposite was true. To refactor Inkscape’s unit support, I had to learn the details of all the different unit handling systems and become familiar with the rest of the code they interacted with. Inkscape contains over 500k lines of code, and learning the code base was the most time consuming part of this project. By the time I finished phase one, I was familiar with the unit support code and the code that used it, so extending unit support was fairly straightforward. The most difficult part of phase two was tracking down and fixing transform bugs the were manifested during document unit changes.

Highlights of phase two include:

  • Use of real world units for page sizes
  • Use of real world document units via a viewBox
  • Refactor of expression evaluator and addition of exponent operator to it
  • Addition of expression evaluator support to toolbars


The unit support refactor during phase one made these improvements possible and will ease the development of future improvements. With the exception of object specific unit support, I finished everything in my proposal. In working on the project, I decided, due to the way units are defined in the SVG specification, that there’s no good way to store object specific units. This leaves having an Inkscape specific attribute that only affects the UI, but I’m not even sure if this behavior is desirable.

Two other ideas I picked up along the way that I would have liked to implement but didn’t get around to are an option to flip the y-axis in Inkscape and a configurable pixel to real world unit ratio. Implementing the former would involve some extensive refactoring due to the parts of Inkscape that are tied directly to the current document coordinate system. To say the latter isn’t implemented is only partially true. With the completion of phase one, all of Inkscape’s unit conversions are defined in units.xml. By editing this file, one can change the conversion factors Inkscape uses. For example, here is a units.xml file using a 10px/mm ratio. The preceding file uses millimeters as the primary unit of length, unlike the current units.xml file that uses pixels. Therefore, the preceding file allows one to change the pixel to real world unit ratio by changing one line. An option could be added to the Inkscape preferences dialog to override this line, allowing one to easily set one’s preferred ratio, something I might add in the future.

I would like to thank my mentor, Johan Engelen, for his support and encouragement throughout this project, as well as the Inkscape community and Google for giving me this wonderful opportunity. It has been a good summer, and I hope to remain involved in the project for the foreseeable future.

This entry was posted in and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.