On 08/14/2011 11:28 AM, Vlastimil Brom wrote: > #################################################### > > Regarding wxagg, it seems, that the suggestion about unsuitable fonts > being used was correct; > after setting the font to Arial, adapted from: > http://matplotlib.sourceforge.net/examples/api/font_family_rc.html > all the characters in the title are displayed ok. > > #################################################### > #! Python > # -*- coding: utf-8 -*- > > import wxversion > wxversion.select('2.9.2') # 2.9.2.1 > import wx > > # setting the font to Arial - the title is displayed completely; > # with the default font only the "latin-1" characters are shown > from matplotlib import rcParams > rcParams['font.family'] = 'sans-serif' > rcParams['font.sans-serif'] = ['Arial'] + rcParams['font.sans-serif'] > # > > import matplotlib > matplotlib.use('WXAgg') > import pylab > > pylab.plot(range(3), range(3)) > pylab.title(u"abcd áčďéěíňóřšťúůýž äöüß ê αβγδ абвгд אבגד xyz") > pylab.show() > > #################################################### > (using python 2.7.2, MPL 1.0.1; Win 7, Czech) > > Is there maybe some machanism available in matplotlib, which would > select the appropriate font for the given characters? (Like in wx or, > even more powerful in tk?) Or is it the expected way to set the > suitable font individually, as only the font list in rcParams are > tried sequentially - regardless of the character support? That's correct: matplotlib doesn't currently do this. It renders a particular string of text with a single font and does not do font substitution for characters that are not in that font. The best practice is to use a font that contains the full set of characters, such as Arial or Deja Vu as you've discovered.
There a lot of other i18n shortcomings to the way matplotlib supports text (such as a lack of bidi support). That's a large wheel to reinvent, so the solution would involve using a third-party text layout library such as pango, but I know there is licensing friction against that. It may be worth revisiting that at some point. Mike ------------------------------------------------------------------------------ uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users