mathtext, tkagg in cvs

Todd Miller has added a TkAgg backend to CVS. As the name implies,
this is a Tkinter GUI backend which uses agg to render. One very nice
feature of this backend is that it works interactively from any python
shell, though you'll still need to set matplotlib.interactive(True).

  > python -i yourscript.py -dTkAgg

There may be a few minor issues to clear up, but it will be included
in the next release, so now would be a good time to test it out
(Thanks Todd!)

Also, following Paul Barrett's pointer to the BaKoMa fonts, I
implemented a TeX math parser which works with the new ft2font module
to render math text. Any text element (xlabel, ylabel, title, text,
etc) can use TeX markup, as in

xlabel(r'$\Delta_i$')
       ^
    use raw strings

The $ symbols must be the first and last symbols in the string. Eg,
you cannot do

  r'My label $x_i$'.

But you can change fonts, as in

  r'\rm{My label} x_y'

to achieve the same effect.

A large set of the TeX symbols are provided (see below). Subscripting
and superscripting are supported, as well as the over/under style of
subscripting with \sum, \int, etc.

The module uses pyparsing to parse the TeX expression, an so can
handle fairly complex TeX expressions
Eg, the following renders correctly

tex = r'$\cal{R}\prod_{i=\alpha_{i+1}}^\infty a_i\rm{sin}(2 \pi f x_i)$'

See http://nitace.bsd.uchicago.edu:8080/files/share/mathtext_demo.png
for a screenshot.

The fonts \cal, \rm, \it, and \tt are defined.

The computer modern fonts this package uses are part of the BaKoMa
fonts, which are (in my understanding) free for noncommercial use.
For commercial use, please consult the licenses in fonts/ttf and the
author Basil K. Malyshev - see also
http://www.mozilla.org/projects/mathml/fonts/encoding/license-bakoma.txt

KNOWN ISSUES:

- some hackish ways I deal with a strange offset in cmex10
- bbox is a bit large in vertical direction and small in horizontal direction
- nested subscripts, eg, x_i_i not working
- nesting fonts changes in sub/superscript groups not parsing
- no rotations yet
- no kerning

I would like to add more layout commands, like \frac.

Backends: This currently works with Agg, GTKAgg and TkAgg. If David
incorporates ft2font into paint, it will be easy to add to Paint. I
think I can also add it to GTK rather straightforwardly, since it's
just a matter of rendering from the ft2font pixel buffers; ditto for
wx. PS will require more substantial work, doing the metrics and
layouts with the AFM versions of the computer modern fonts. Backends
which don't support mathtext will just render the TeX string as a
literal.

CVS is updated - or if you prefer, I uploaded a snapshot to
http://nitace.bsd.uchicago.edu:8080/files/share/matplotlib-0.51c.tar.gz

Let me know how it goes! I expect there will be plenty of issues
cropping up.

JDH

Allowed TeX symbols:

\Delta \Downarrow \Gamma \Im \LEFTangle \LEFTbrace \LEFTbracket
\LEFTparen \Lambda \Leftarrow \Leftbrace \Leftbracket \Leftparen
\Leftrightarrow \Omega \P \Phi \Pi \Psi \RIGHTangle \RIGHTbrace
\RIGHTbracket \RIGHTparen \Re \Rightarrow \Rightbrace \Rightbracket
\Rightparen \S \SQRT \Sigma \Sqrt \Theta \Uparrow \Updownarrow
\Upsilon \Vert \Xi \aleph \alpha \approx \ast \asymp \backslash \beta
\bigcap \bigcirc \bigcup \bigodot \bigoplus \bigotimes
\bigtriangledown \bigtriangleup \biguplus \bigvee \bigwedge \bot
\bullet \cap \cdot \chi \circ \clubsuit \coprod \cup \dag \dashv \ddag
\delta \diamond \diamondsuit \div \downarrow \ell \emptyset \epsilon
\equiv \eta \exists \flat \forall \frown \gamma \geq \gg \heartsuit
\imath \in \infty \int \iota \jmath \kappa \lambda \langle \lbrace
\lceil \leftangle \leftarrow \leftbrace \leftbracket \leftharpoondown
\leftharpoonup \leftparen \leftrightarrow \leq \lfloor \ll \mid \mp
\mu \nabla \natural \nearrow \neg \ni \nu \nwarrow \odot \oint \omega
\ominus \oplus \oslash \otimes \phi \pi \pm \prec \preceq \prime \prod
\propto \psi \rangle \rbrace \rceil \rfloor \rho \rightangle
\rightarrow \rightbrace \rightbracket \rightharpoondown
\rightharpoonup \rightparen \searrow \sharp \sigma \sim \simeq \slash
\smile \spadesuit \sqcap \sqcup \sqrt \sqsubseteq \sqsupseteq \subset
\subseteq \succ \succeq \sum \supset \supseteq \swarrow \tau \theta
\times \top \triangleleft \triangleright \uparrow \updownarrow \uplus
\upsilon \varepsilon \varphi \varphi \varrho \varsigma \vartheta
\vdash \vee \wedge \wp \wr \xi \zeta