mathtext in SVG backend

Hello, The attached patches implement mathtext for SVG. The

    > output looks pretty good when viewed by Inkscape, but not
    > the Adobe SVG viewer (it shows the wrong symbols and then
    > moments later crashes Mozilla, at least on my system). It
    > hasn't been thoroughly tested for all of the possible
    > symbols.

Hmm, this is strange and intriguing. I notice that you do not embed
the fonts in your svg document, which is presumably why most viewers
can't handle it. I confirmed that librsvg, which gqview uses, can't
render the fonts either. The question is, why can Inkscape do it? I
downloaded Inkscape and did a recursive grep through their src as well
as a find in the root of their src tree and found no references to
'computer modern' or cmex, etc.... Did you have to set some path in
inkscape to see your cm fonts, or did you put them in some standard
place? Anyone have any ideas how inkscape manages to pull off this
trick?

    > I had to add a math_parse_s_ft2font_svg() to mathtext.py,
    > which basically does the same thing as
    > math_parse_s_ft2font() but returns something different. I
    > tried to just modify the latter function to take a
    > "usingSVG=True" argument and ran into all sorts of bizarre
    > problems, probably associated with the caching, and gave
    > up. Perhaps someone can figure out how to do this more
    > elegantly.

Probably the best way to do this is to subclass BakomaTrueTypeFonts
and override the just methods you need.

    > John, are there any more features still missing from the
    > SVG backend?

That almost does it. I think we need an option to embed the fonts
directly into the svg document like we do for PS, because I think
viewers that have the cm* fonts built in will be the exception rather
than the rule. Fernando Perez has some colleagues who are interested
in embedding clickable tags in svg, but I haven't heard much from
them.

But overall SVG is in fine shape.

Many thanks!
JDH

Yeah, now I remember installing those fonts a while ago so I could put
symbols in my diagrams in inkscape...

For embedding, we need SVG fonts. Would it be kosher to just use this:

http://xml.apache.org/batik/ttf2svg.html

or its equivalent to convert the BaKoMa fonts to SVG, and then include
the resulting SVG fonts in the matplotlib package?

Jared

···

Hmm, this is strange and intriguing. I notice that you do not embed
the fonts in your svg document, which is presumably why most viewers
can't handle it. I confirmed that librsvg, which gqview uses, can't
render the fonts either. The question is, why can Inkscape do it? I
downloaded Inkscape and did a recursive grep through their src as well
as a find in the root of their src tree and found no references to
'computer modern' or cmex, etc.... Did you have to set some path in
inkscape to see your cm fonts, or did you put them in some standard
place? Anyone have any ideas how inkscape manages to pull off this
trick?

    > John, are there any more features still missing from the
    > SVG backend?

That almost does it. I think we need an option to embed the fonts
directly into the svg document like we do for PS, because I think
viewers that have the cm* fonts built in will be the exception rather
than the rule. Fernando Perez has some colleagues who are interested
in embedding clickable tags in svg, but I haven't heard much from
them.

But overall SVG is in fine shape.