From: John H. <jdh...@ac...> - 2005-01-18 21:55:37
|
>>>>> "Matt" == Matt Newville <new...@ca...> writes: Matt> Sorry for the confusion, that's not what I meant. I think Matt> that the acute sign would have to be added to the list of Matt> symbols that mathtext can handle. That would probably mean Matt> both special code in mathtext.py and an entry in Matt> _mathtext_data.py. I'm not sure what the right entry in the Matt> font table would be, as I don't understand the entries in Matt> the latex_to_bakoma dictionary in _mathtext_data.py at all. I just added support for accents in general to mathtext. The following accents are provided: \hat, \breve, \grave, \bar, \acute, \tilde, \vec, \dot, \ddot. All of them have the same syntax, eg to make an overbar you do \bar{o} or to make an o umlaut you do \ddot{o}. The changes are in CVS - make sure you get mathtext.py revision 1.9 or later, and _mathtext_data.py revision 1.5 or later. Here is the test script I used: from pylab import * plot(range(10)) title(r'$\ddot{o}\acute{e}\grave{e}\hat{O}\breve{i}\bar{A}\tilde{n}\vec{q}\dot{x}$', fontsize=20) show() Hope this helps! JDH PS: Matt, the _mathtext_data dictionary latex_to_bakoma maps the TeX symbol to a fontfilename, glyph index tuple. To get the character code in the font file corresponding to the glyph index, you can use the FT2Font charmap dict Here's a little demo script which shows you how to use the dict to load a freetype2 glyph struct for a latex symbol "delta" from the appropriate cm*.ttf file import os from matplotlib import get_data_path from matplotlib.ft2font import FT2Font from matplotlib._mathtext_data import latex_to_bakoma name, glyphind = latex_to_bakoma[r'\delta'] fname = os.path.join(get_data_path(), name + '.ttf') font = FT2Font(fname) charmap = font.get_charmap() ccode = charmap[glyphind] glyph = font.load_char(ccode) print glyph.width/64. |