The puzzling thing is this: u'C:\\WINDOWS\\Fonts\\HTOWERTI.TTF'
It's using a custom font in mathtext. Are you setting the rcParams mathtext.fontset or mathtext.default? That may the culprit, and if not, it's a bug that it's trying to use that font. Mike william ratcliff wrote: > On the plus side, there is no longer an error when I apply the patch. On > the downside, it generates a rather strange symbol instead of a > perpendicular symbol....Let me try to quickly upgrade to 0.99.1. I did that > and I seem to get the same error... > > On Mon, Apr 19, 2010 at 10:49 AM, Michael Droettboom <md...@stsci.edu>wrote: > > >> Does forcibly casting the path to a string resolve the problem? i.e. >> applying this patch: >> >> Index: mathtext.py >> =================================================================== >> --- mathtext.py (revision 8216) >> +++ mathtext.py (working copy) >> @@ -597,7 +597,7 @@ >> >> cached_font = self._fonts.get(basename) >> if cached_font is None: >> - font = FT2Font(basename) >> + font = FT2Font(str(basename)) >> cached_font = self.CachedFont(font) >> self._fonts[basename] = cached_font >> self._fonts[font.postscript_name] = cached_font >> >> Mike >> >> william ratcliff wrote: >> >> >>> Mike, >>> >>> The basename is: >>> u'C:\\WINDOWS\\Fonts\\HTOWERTI.TTF' >>> >>> Let me try to find where my matplotlibrc file is located... >>> >>> Thanks, >>> William >>> >>> On Mon, Apr 19, 2010 at 10:22 AM, Michael Droettboom >>> <md...@stsci.edu<mailto: >>> md...@stsci.edu>> wrote: >>> >>> One might see that error if the path to the font being used >>> contains non-ascii characters (the "basename" variable in the last >>> frame of the stack in the stacktrace). Is that possible? We may >>> need to implement the same workaround we use for image files for >>> loading fonts (which is to open the file with Python and pass a >>> file handle to C++ rather than passing a string that may contain >>> Unicode, which is difficult to handle in cross-platform way from >>> C/C++). >>> >>> Mike >>> >>> william ratcliff wrote: >>> >>> I think the actual error was: >>> TypeError: cannot return std::string from Unicode object >>> >>> It was the error returned when I walked through with a debugger... >>> >>> On Mon, Apr 19, 2010 at 8:51 AM, Michael Droettboom >>> <md...@stsci.edu <mailto:md...@stsci.edu> >>> <mailto:md...@stsci.edu <mailto:md...@stsci.edu>>> wrote: >>> >>> It looks like the end of the traceback -- where the actual >>> exception is named -- is missing. Can you repost it in its >>> entirety? >>> >>> Mike >>> >>> william ratcliff wrote: >>> >>> Hi! I am using matplotlib 0.99.0 under windows xp. I >>> tried >>> the following: >>> ax.text(.96,.80,r'$P \perp >>> >>> >>> Q$',fontsize=18,horizontalalignment='right',verticalalignment='top',transform=ax.transAxes,color='black') >>> and get the following error: >>> (However, in figure labels, symbols using mathtext, such as >>> theta seem to work fine...) >>> >>> Thanks, >>> William >>> >>> TypeError: cannot return std::string from Unicode object >>> File >>> >>> "C:\mytripleaxisproject\trunk\eclipse\src\utilities\bfo_film_fig2.py", >>> line 301, in <module> >>> film110() >>> File >>> >>> "C:\mytripleaxisproject\trunk\eclipse\src\utilities\bfo_film_fig2.py", >>> line 157, in film110 >>> plt.show() >>> File >>> >>> "C:\Python25\Lib\site-packages\matplotlib\backends\backend_qt4.py", >>> line 63, in show >>> manager.window.show() >>> File >>> >>> "C:\Python25\Lib\site-packages\matplotlib\backends\backend_qt4.py", >>> line 168, in resizeEvent >>> self.draw() >>> File >>> >>> "C:\Python25\Lib\site-packages\matplotlib\backends\backend_qt4agg.py", >>> line 130, in draw >>> FigureCanvasAgg.draw(self) >>> File >>> >>> "C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py", >>> line 314, in draw >>> self.figure.draw(self.renderer) >>> File "C:\Python25\Lib\site-packages\matplotlib\artist.py", >>> line 46, in draw_wrapper >>> draw(artist, renderer, *kl) >>> File "C:\Python25\Lib\site-packages\matplotlib\figure.py", >>> line 774, in draw >>> for a in self.axes: a.draw(renderer) >>> File "C:\Python25\Lib\site-packages\matplotlib\artist.py", >>> line 46, in draw_wrapper >>> draw(artist, renderer, *kl) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\axes.py", line >>> 1721, in draw >>> a.draw(renderer) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\text.py", line >>> 515, in draw >>> bbox, info = self._get_layout(renderer) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\text.py", line >>> 279, in _get_layout >>> clean_line, self._fontproperties, ismath=ismath) >>> File >>> >>> "C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py", >>> line 156, in get_text_width_height_descent >>> self.mathtext_parser.parse(s, self.dpi, prop) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\mathtext.py", >>> line 2810, in parse >>> box = self._parser.parse(s, font_output, fontsize, dpi) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\mathtext.py", >>> line 2259, in parse >>> self._expression.parseString(s) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 1048, in parseString >>> loc, tokens = self._parse( instring, 0 ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 924, in _parseNoCache >>> loc,tokens = self.parseImpl( instring, preloc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 2559, in parseImpl >>> return self.expr._parse( instring, loc, doActions, >>> callPreParse=False ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 924, in _parseNoCache >>> loc,tokens = self.parseImpl( instring, preloc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 2307, in parseImpl >>> loc, exprtokens = e._parse( instring, loc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 924, in _parseNoCache >>> loc,tokens = self.parseImpl( instring, preloc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 2672, in parseImpl >>> loc, tokens = self.expr._parse( instring, loc, doActions, >>> callPreParse=False ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 924, in _parseNoCache >>> loc,tokens = self.parseImpl( instring, preloc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 2307, in parseImpl >>> loc, exprtokens = e._parse( instring, loc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 924, in _parseNoCache >>> loc,tokens = self.parseImpl( instring, preloc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 2756, in parseImpl >>> loc, tokens = self.expr._parse( instring, loc, doActions, >>> callPreParse=False ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 924, in _parseNoCache >>> loc,tokens = self.parseImpl( instring, preloc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 2714, in parseImpl >>> loc, tmptokens = self.expr._parse( instring, preloc, >>> doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 924, in _parseNoCache >>> loc,tokens = self.parseImpl( instring, preloc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 2373, in parseImpl >>> return maxMatchExp._parse( instring, loc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 924, in _parseNoCache >>> loc,tokens = self.parseImpl( instring, preloc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 2559, in parseImpl >>> return self.expr._parse( instring, loc, doActions, >>> callPreParse=False ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 924, in _parseNoCache >>> loc,tokens = self.parseImpl( instring, preloc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 2416, in parseImpl >>> ret = e._parse( instring, loc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 924, in _parseNoCache >>> loc,tokens = self.parseImpl( instring, preloc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 2559, in parseImpl >>> return self.expr._parse( instring, loc, doActions, >>> callPreParse=False ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 924, in _parseNoCache >>> loc,tokens = self.parseImpl( instring, preloc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 2559, in parseImpl >>> return self.expr._parse( instring, loc, doActions, >>> callPreParse=False ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 924, in _parseNoCache >>> loc,tokens = self.parseImpl( instring, preloc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 2416, in parseImpl >>> ret = e._parse( instring, loc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 924, in _parseNoCache >>> loc,tokens = self.parseImpl( instring, preloc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 2293, in parseImpl >>> loc, resultlist = self.exprs[0]._parse( instring, loc, >>> doActions, callPreParse=False ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 924, in _parseNoCache >>> loc,tokens = self.parseImpl( instring, preloc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 2756, in parseImpl >>> loc, tokens = self.expr._parse( instring, loc, doActions, >>> callPreParse=False ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 924, in _parseNoCache >>> loc,tokens = self.parseImpl( instring, preloc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 2559, in parseImpl >>> return self.expr._parse( instring, loc, doActions, >>> callPreParse=False ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 924, in _parseNoCache >>> loc,tokens = self.parseImpl( instring, preloc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 2373, in parseImpl >>> return maxMatchExp._parse( instring, loc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 924, in _parseNoCache >>> loc,tokens = self.parseImpl( instring, preloc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 2416, in parseImpl >>> ret = e._parse( instring, loc, doActions ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 981, in _parseCache >>> value = self._parseNoCache( instring, loc, doActions, >>> callPreParse ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\pyparsing.py", >>> line 950, in _parseNoCache >>> tokens = fn( instring, tokensStart, retTokens ) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\mathtext.py", >>> line 2374, in symbol >>> char = Char(c, self.get_state()) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\mathtext.py", >>> line 1264, in __init__ >>> self._update_metrics() >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\mathtext.py", >>> line 1271, in _update_metrics >>> self.font, self.font_class, self.c, self.fontsize, >>> self.dpi) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\mathtext.py", >>> line 446, in get_metrics >>> info = self._get_info(font, font_class, sym, fontsize, >>> dpi) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\mathtext.py", >>> line 579, in _get_info >>> self._get_glyph(fontname, font_class, sym, fontsize) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\mathtext.py", >>> line 697, in _get_glyph >>> fontname, font_class, sym, fontsize) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\mathtext.py", >>> line 827, in _get_glyph >>> cached_font = self._get_font(new_fontname) >>> File >>> "C:\Python25\Lib\site-packages\matplotlib\mathtext.py", >>> line 560, in _get_font >>> font = FT2Font(basename) >>> >>> >>> ------------------------------------------------------------------------ >>> >>> >>> >>> ------------------------------------------------------------------------------ >>> Download Intel® Parallel Studio Eval >>> Try the new software tools for yourself. Speed >>> compiling, find >>> bugs >>> proactively, and fine-tune applications for parallel >>> performance. >>> See why Intel Parallel Studio got high marks during beta. >>> http://p.sf.net/sfu/intel-sw-dev >>> >>> ------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Matplotlib-users@lists.sourceforge.net >>> <mailto:Matplotlib-users@lists.sourceforge.net> >>> <mailto:Matplotlib-users@lists.sourceforge.net >>> <mailto:Matplotlib-users@lists.sourceforge.net>> >>> >>> >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >>> -- Michael Droettboom >>> Science Software Branch >>> Operations and Engineering Division >>> Space Telescope Science Institute >>> Operated by AURA for NASA >>> >>> >>> >>> -- Michael Droettboom >>> Science Software Branch >>> Operations and Engineering Division >>> Space Telescope Science Institute >>> Operated by AURA for NASA >>> >>> >>> >>> >> -- >> Michael Droettboom >> Science Software Branch >> Operations and Engineering Division >> Space Telescope Science Institute >> Operated by AURA for NASA >> >> >> > > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users