using matplotlib.mathtext standalone

Hi all,

(A bit off-topic, hope this is ok, please redirect me if this is more
appropriate on a different list).

I am interested in using the mathtext rendering functionality separate
from the plotting part of matplotlib. To be precise, I would like to
use mathtext as a replacement mathematics renderer in the notebook
front-end of my symbolic computer algebra system 'cadabra',

(right now I am using latex/dvipng to render mathematical expressions,
which is slow and not very flexible).

I would prefer to use mathtext to render onto a cairo drawing surface
(since I already have plans to use cairo to improve the
front-end). Are there any examples showing how to do this, or could
someone perhaps post a small code snippet to get me started? Thanks!