Not hard, I don't think. The following will give you a FT2Image object
of the expression:
from matplotlib.mathtext import MathTextParser
mathtext_parser = MathTextParser("Bitmap")
ftimage = mathtext_parser.parse(r"$x^i$", 150)
From the FT2Image, you can get an rgba buffer, and the width and the
height.
Here's where it gets (a little) tricky -->
We have code to save RendererAgg buffers, and Image buffers, but nothing
to take a pointer to raw C rgba buffer and width and height. We could
a) depend on Gtk or Wx to save the mathtext PNG (which can do this now,
see mathtext_wx.py), or b) create a new png-writing C-extension which
would take a raw buffer, width, height and a filename/file object.
Then, we could remove some code duplication by making _backend_agg.cpp
and _image.cpp use that.
I won't have time to get to this immediately. Hopefully that's enough
of a roadmap for someone else to take it.
Cheers,
Mike
John Hunter wrote:
> We are currently using latex dvipng pngs in our html docs to avoid the
> mathml browser limitations. I don't have latex on my OSX box, which
> is no really a big problem since I have ssh access to a fully
> configured linux box, but it would be really cool to drop this
> dependency and use mathtext instead. Truth in advertising after all
> -- eg in the mathtext chapter I'd much rather show them *our*
> equations than latex's, even though they are damn close.
>
> Michael - -how hard would it be to generate small PNGs of mpl rendered
> equations rather than use latex/dvipng here?
>
> JDH
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Matplotlib-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel