Question about mathtext

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

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)

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&#174; 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
matplotlib-users List Signup and Options
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

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 <mdroe@…86…> 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

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

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

I'm not able to reproduce that here, with either SVN or 0.99.1.2. Do you have any font-related or mathtext-related settings in your matplotlibrc?

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 <mdroe@...86... > <mailto:mdroe@…86…>> 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 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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&#174; 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>
        matplotlib-users List Signup and Options
         
    -- 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

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 <mdroe@...86... > <mailto:mdroe@…86…>> 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 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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&#174; 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>
        matplotlib-users List Signup and Options
         
    -- 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

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 <mdroe@…86…> 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 <mdroe@…86… mailto:mdroe@...86...> 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&#174; 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](http://p.sf.net/sfu/intel-sw-dev)

    ------------------------------------------------------------------------



    _______________________________________________

    Matplotlib-users mailing list

    Matplotlib-users@lists.sourceforge.net

mailto:Matplotlib-users@lists.sourceforge.net

    [https://lists.sourceforge.net/lists/listinfo/matplotlib-users](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

Assuming that the matplotlibrc file being read is in mpl-data, here is the relevant section:

FONT

···

font properties used by text.Text. See

http://matplotlib.sourceforge.net/api/font_manager_api.html for more

information on font properties. The 6 font properties used for font

matching are given below with their default values.

The font.family property has five values: ‘serif’ (e.g. Times),

‘sans-serif’ (e.g. Helvetica), ‘cursive’ (e.g. Zapf-Chancery),

‘fantasy’ (e.g. Western), and ‘monospace’ (e.g. Courier). Each of

these font families has a default list of font names in decreasing

order of priority associated with them.

The font.style property has three values: normal (or roman), italic

or oblique. The oblique style will be used for italic, if it is not

present.

The font.variant property has two values: normal or small-caps. For

TrueType fonts, which are scalable fonts, small-caps is equivalent

to using a font size of ‘smaller’, or about 83% of the current font

size.

The font.weight property has effectively 13 values: normal, bold,

bolder, lighter, 100, 200, 300, …, 900. Normal is the same as

400, and bold is 700. bolder and lighter are relative values with

respect to the current weight.

The font.stretch property has 11 values: ultra-condensed,

extra-condensed, condensed, semi-condensed, normal, semi-expanded,

expanded, extra-expanded, ultra-expanded, wider, and narrower. This

property is not currently implemented.

The font.size property is the default font size for text, given in pts.

12pt is the standard value.

#font.family : sans-serif

#font.style : normal

#font.variant : normal

#font.weight : medium

#font.stretch : normal

note that font.size controls default text sizes. To configure

special text sizes tick labels, axes, labels, title, etc, see the rc

settings for axes and ticks. Special text sizes can be defined

relative to font.size, using the following values: xx-small, x-small,

small, medium, large, x-large, xx-large, larger, or smaller

#font.size : 12.0

#font.serif : Bitstream Vera Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif

#font.sans-serif : Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif

#font.cursive : Apple Chancery, Textile, Zapf Chancery, Sand, cursive

#font.fantasy : Comic Sans MS, Chicago, Charcoal, Impact, Western, fantasy

#font.monospace : Bitstream Vera Sans Mono, Andale Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace

TEXT

text properties used by text.Text. See

http://matplotlib.sourceforge.net/api/artist_api.html#module-matplotlib.text for more

information on text properties

#text.color : black

LaTeX customizations. See http://www.scipy.org/Wiki/Cookbook/Matplotlib/UsingTex

#text.usetex : False # use latex for all text handling. The following fonts

are supported through the usual rc parameter settings:

new century schoolbook, bookman, times, palatino,

zapf chancery, charter, serif, sans-serif, helvetica,

avant garde, courier, monospace, computer modern roman,

computer modern sans serif, computer modern typewriter

If another font is desired which can loaded using the

LaTeX \usepackage command, please inquire at the

matplotlib mailing list

#text.latex.unicode : False # use “ucs” and “inputenc” LaTeX packages for handling

unicode strings.

#text.latex.preamble : # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURES

AND IS THEREFORE UNSUPPORTED. PLEASE DO NOT ASK FOR HELP

IF THIS FEATURE DOES NOT DO WHAT YOU EXPECT IT TO.

preamble is a comma separated list of LaTeX statements

that are included in the LaTeX document preamble.

An example:

text.latex.preamble : \usepackage{bm},\usepackage{euler}

The following packages are always loaded with usetex, so

beware of package collisions: color, geometry, graphicx,

type1cm, textcomp. Adobe Postscript (PSSNFS) font packages

may also be loaded, depending on your font settings

#text.dvipnghack : None # some versions of dvipng don’t handle alpha

channel properly. Use True to correct

and flush ~/.matplotlib/tex.cache

before testing and False to force

correction off. None will try and

guess based on your dvipng version

#text.markup : ‘plain’ # Affects how text, such as titles and labels, are

interpreted by default.

‘plain’: As plain, unformatted text

			# 'tex': As TeX-like text.  Text between $'s will be

			# formatted as a TeX math expression.

			# This setting has no effect when text.usetex is True.

			# In that case, all text will be sent to TeX for

			# processing.

The following settings allow you to select the fonts in math mode.

They map from a TeX font name to a fontconfig font pattern.

These settings are only used if mathtext.fontset is ‘custom’.

Note that this “custom” mode is unsupported and may go away in the

future.

#mathtext.cal : cursive

#mathtext.rm : serif

#mathtext.tt : monospace

#mathtext.it : serif:italic

#mathtext.bf : serif:bold

#mathtext.sf : sans

#mathtext.fontset : cm # Should be ‘cm’ (Computer Modern), ‘stix’,

‘stixsans’ or ‘custom’

#mathtext.fallback_to_cm : True # When True, use symbols from the Computer Modern

		         # fonts when a symbol can not be found in one of

			 # the custom math fonts.

#mathtext.default : it # The default font to use for math.

Can be any of the LaTeX font names, including

the special name “regular” for the same font

used in regular text.

On Mon, Apr 19, 2010 at 10:41 AM, william ratcliff <william.ratcliff@…287…> 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 <mdroe@…86…> 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 <mdroe@…86… mailto:mdroe@...86...> 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&#174; 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](http://p.sf.net/sfu/intel-sw-dev)

    ------------------------------------------------------------------------



    _______________________________________________

    Matplotlib-users mailing list

    Matplotlib-users@lists.sourceforge.net

mailto:Matplotlib-users@lists.sourceforge.net

    [https://lists.sourceforge.net/lists/listinfo/matplotlib-users](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

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 <mdroe@...86... > <mailto:mdroe@…86…>> 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 > <mdroe@...86... <mailto:mdroe@…86…> > <mailto:mdroe@…86…>> 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 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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&#174; 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>>

                      matplotlib-users List Signup and Options
               
           -- 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

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 <mdroe@…920…6…> 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 <mdroe@…86… mailto:mdroe@...86...> 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 > >  > >         <mdroe@...86... <mailto:mdroe@...86...> > > <mailto:mdroe@...86... <mailto:mdroe@...86...>>> 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&#174; 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](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@...1738....net

    <mailto:Matplotlib-users@lists.sourceforge.net>>



                  [https://lists.sourceforge.net/lists/listinfo/matplotlib-users](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

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 <mdroe@...86...>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 <mdroe@...86...<mailto: >>> mdroe@...86...>> 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 >>> <mdroe@...86... <mailto:mdroe@…86…> >>> <mailto:mdroe@…86…>> 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&#174; 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>>

matplotlib-users List Signup and Options

          -- 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

From my mpl-data directory, here’s what’s in the mathtext section of my matplotlibrc file:

The following settings allow you to select the fonts in math mode.

They map from a TeX font name to a fontconfig font pattern.

These settings are only used if mathtext.fontset is ‘custom’.

Note that this “custom” mode is unsupported and may go away in the

future.

#mathtext.cal : cursive

#mathtext.rm : serif

#mathtext.tt : monospace

#mathtext.it : serif:italic

#mathtext.bf : serif:bold

#mathtext.sf : sans

#mathtext.fontset : cm # Should be ‘cm’ (Computer Modern), ‘stix’,

‘stixsans’ or ‘custom’

mathtext.fallback_to_cm : True # When True, use symbols from the Computer Modern

		         # fonts when a symbol can not be found in one of

			 # the custom math fonts.

#mathtext.default : it # The default font to use for math.

Can be any of the LaTeX font names, including

the special name “regular” for the same font

···

On Mon, Apr 19, 2010 at 2:40 PM, Michael Droettboom <mdroe@…86…> wrote:

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 <mdroe@…86…>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 <mdroe@…86…<mailto: > > > > > > > > mdroe@…86…>> 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 > > > >  > > > >        <mdroe@...86... <mailto:mdroe@...86...> > > > >  > > > >        <mailto:mdroe@...86... <mailto:mdroe@...86...>>> 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&#174; 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](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@...564...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

Hmm... I'm a bit stumped. Can you print out the values of these from your script, i.e. put the following at the top:

  from matplotlib import rcParams
  print rcParams['mathtext.fontset']
  print rcParams['mathtext.default']

Can you try deleting your fontList.cache file?

Mike

william ratcliff wrote:

···

From my mpl-data directory, here's what's in the mathtext section of my
matplotlibrc file:
# The following settings allow you to select the fonts in math mode.
# They map from a TeX font name to a fontconfig font pattern.
# These settings are only used if mathtext.fontset is 'custom'.
# Note that this "custom" mode is unsupported and may go away in the
# future.
#mathtext.cal : cursive
#mathtext.rm : serif
#mathtext.tt : monospace
#mathtext.it : serif:italic
#mathtext.bf : serif:bold
#mathtext.sf : sans
#mathtext.fontset : cm # Should be 'cm' (Computer Modern), 'stix',
                       # 'stixsans' or 'custom'
mathtext.fallback_to_cm : True # When True, use symbols from the Computer
Modern
         # fonts when a symbol can not be found in one of
# the custom math fonts.

#mathtext.default : it # The default font to use for math.
                       # Can be any of the LaTeX font names, including
                       # the special name "regular" for the same font

On Mon, Apr 19, 2010 at 2:40 PM, Michael Droettboom <mdroe@...86...> wrote:

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 <mdroe@...86... >>> >>>> 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 <mdroe@...86... >>>>> <mailto: >>>>> mdroe@...86...>> 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 >>>>> <mdroe@...86... <mailto:mdroe@…86…> >>>>> <mailto:mdroe@…86…>> 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&#174; 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>>

matplotlib-users List Signup and Options

         -- 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

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Progress:

c:\python25\lib\site-packages\matplotlib\mathtext.py:848: MathTextWarning: Font ‘rm’ does not have a glyph for ‘\perp’

MathTextWarning)

c:\python25\lib\site-packages\matplotlib\mathtext.py:849: MathTextWarning: Substituting with a dummy symbol.

warn(“Substituting with a dummy symbol.”, MathTextWarning)

···

Next, I followed your suggestion and deleted the fontlist.cache file and that solved everything. Thanks!!!

So, that’s where the dummy symbol is coming from.

On Mon, Apr 19, 2010 at 3:42 PM, Michael Droettboom <mdroe@…120…86…> wrote:

Hmm… I’m a bit stumped. Can you print out the values of these from your script, i.e. put the following at the top:

from matplotlib import rcParams

print rcParams[‘mathtext.fontset’]

print rcParams[‘mathtext.default’]

Can you try deleting your fontList.cache file?

Mike

william ratcliff wrote:

From my mpl-data directory, here’s what’s in the mathtext section of my

matplotlibrc file:

The following settings allow you to select the fonts in math mode.

They map from a TeX font name to a fontconfig font pattern.

These settings are only used if mathtext.fontset is ‘custom’.

Note that this “custom” mode is unsupported and may go away in the

future.

#mathtext.cal : cursive

#mathtext.rm : serif

#mathtext.tt : monospace

#mathtext.it : serif:italic

#mathtext.bf : serif:bold

#mathtext.sf : sans

#mathtext.fontset : cm # Should be ‘cm’ (Computer Modern), ‘stix’,

                   # 'stixsans' or 'custom'

mathtext.fallback_to_cm : True # When True, use symbols from the Computer

Modern

     # fonts when a symbol can not be found in one of

the custom math fonts.

#mathtext.default : it # The default font to use for math.

                   # Can be any of the LaTeX font names, including

                   # the special name "regular" for the same font

On Mon, Apr 19, 2010 at 2:40 PM, Michael Droettboom <mdroe@…86…> wrote:

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 <mdroe@…86… > > > > > > > > > > > > > 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 <mdroe@…86… > > > > > > > > > > > > <mailto: > > > > > > > > > > > > mdroe@…86…>> 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 > > > > > >  > > > > > >       <mdroe@...120.....86... <mailto:mdroe@...86...> > > > > > >  > > > > > >       <mailto:mdroe@...86... <mailto:mdroe@...86...>>> 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&#174; 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](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

Michael Droettboom

Science Software Branch

Operations and Engineering Division

Space Telescope Science Institute

Operated by AURA for NASA

That's great news -- glad we got to the bottom of it, though I'm not sure how your system may have become wedged like that in the first place. I should have thought of this earlier, but if it happens again, can you send me your fontList.cache file so I can inspect it? There may be a bug in the font lookup code there.

Cheers,
Mike

william ratcliff wrote:

···

Progress:

c:\python25\lib\site-packages\matplotlib\mathtext.py:848: MathTextWarning:
Font 'rm' does not have a glyph for '\perp'
  MathTextWarning)
c:\python25\lib\site-packages\matplotlib\mathtext.py:849: MathTextWarning:
Substituting with a dummy symbol.
  warn("Substituting with a dummy symbol.", MathTextWarning)

----

Next, I followed your suggestion and deleted the fontlist.cache file and
that solved everything. Thanks!!!

So, that's where the dummy symbol is coming from.

On Mon, Apr 19, 2010 at 3:42 PM, Michael Droettboom <mdroe@...86...> wrote:

Hmm... I'm a bit stumped. Can you print out the values of these from your
script, i.e. put the following at the top:

from matplotlib import rcParams
print rcParams['mathtext.fontset']
print rcParams['mathtext.default']

Can you try deleting your fontList.cache file?

Mike

william ratcliff wrote:

From my mpl-data directory, here's what's in the mathtext section of my
matplotlibrc file:
# The following settings allow you to select the fonts in math mode.
# They map from a TeX font name to a fontconfig font pattern.
# These settings are only used if mathtext.fontset is 'custom'.
# Note that this "custom" mode is unsupported and may go away in the
# future.
#mathtext.cal : cursive
#mathtext.rm : serif
#mathtext.tt : monospace
#mathtext.it : serif:italic
#mathtext.bf : serif:bold
#mathtext.sf : sans
#mathtext.fontset : cm # Should be 'cm' (Computer Modern), 'stix',
                      # 'stixsans' or 'custom'
mathtext.fallback_to_cm : True # When True, use symbols from the Computer
Modern
        # fonts when a symbol can not be found in one of
# the custom math fonts.

#mathtext.default : it # The default font to use for math.
                      # Can be any of the LaTeX font names, including
                      # the special name "regular" for the same font

On Mon, Apr 19, 2010 at 2:40 PM, Michael Droettboom <mdroe@...86...> >>> wrote:

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 <mdroe@...86... >>>>> >>>>> >>>>> >>>>>> 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 <mdroe@...86... >>>>>>> <mailto: >>>>>>> mdroe@...86...>> 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 >>>>>>> <mdroe@...86... <mailto:mdroe@…86…> >>>>>>> <mailto:mdroe@…86…>> 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&#174; 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>>

matplotlib-users List Signup and Options

        -- 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

--
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