[cairo] Qahirah: A High-Level Cairo API Binding For Python 3

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Fri Mar 6 15:09:33 PST 2015

It seems like Pycairo <http://cairographics.org/pycairo/> has not had
much TLC in over two years. Besides its incompleteness, it suffers
inherent limitations from being written in C, which would not afflict a
Python binding written in Python.

So here is Qahirah <https://github.com/ldo/qahirah>, yet another Python
binding for Cairo, this one concentrating specifically on Python 3.
Being done in Python, I can go beyond the language limitations of C,
which constrain Cairo itself. Thus, instead of doing separate
calculations on x and y coordinates, I provide a Vector type, allowing
you to do arithmetic along both coordinate axes in a single expression.

Similarly, instead of always having to specify colours with separate R,
G, B and A components, I define a Colour class, which allows you to
work with colours freely in your choice of RGBA, HSVA, HLSA and YIQA
spaces, courtesy of the standard Python colorsys module. Of course, all
colours are automatically converted to RGBA form before being passed to

Other places where Qahirah offers capabilities going beyond Cairo
itself are the Path and Matrix types. I also allow method-chaining for
drawing calls.

In terms of direct support for Cairo functionality, I would say it is
already roughly at feature parity with Pycairo. Cairo features I have
implemented that are not in Pycairo include access to FreeType fonts
and mesh patterns. The main omissions from Qahirah at this point are
regions and the GUI surface types.

Some example scripts are here <https://github.com/ldo/qahirah_examples>.

More information about the cairo mailing list