Revision: 4160 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4160&view=rev Author: mdboom Date: 2007-11-08 06:31:15 -0800 (Thu, 08 Nov 2007)
Log Message: ----------- Throw in dummy characters for symbols not in the Bakoma fonts. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/mathtext.py Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2007-11-08 14:06:25 UTC (rev 4159) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2007-11-08 14:31:15 UTC (rev 4160) @@ -672,6 +672,7 @@ _slanted_symbols = Set(r"\int \oint".split()) def _get_glyph(self, fontname, sym, fontsize): + symbol_name = None if fontname in self.fontmap and latex_to_bakoma.has_key(sym): basename, num = latex_to_bakoma[sym] slanted = (basename == "cmmi10") or sym in self._slanted_symbols @@ -682,11 +683,21 @@ slanted = (fontname == "it") cached_font = self._get_font(fontname) num = ord(sym) - symbol_name = cached_font.font.get_glyph_name( - cached_font.charmap[num]) - else: - raise ValueError('unrecognized symbol "%s"' % sym) + gid = cached_font.charmap.get(num) + if gid is not None: + symbol_name = cached_font.font.get_glyph_name( + cached_font.charmap[num]) + if symbol_name is None: + warn("Unrecognized symbol '%s'. Substituting with a dummy symbol." + % sym.encode('ascii', 'backslashreplace'), MathTextWarning) + fontname = 'it' + cached_font = self._get_font(fontname) + num = 0x3F # currency character, for lack of anything better + gid = cached_font.charmap[num] + symbol_name = cached_font.font.get_glyph_name(gid) + slanted = False + return cached_font, num, symbol_name, fontsize, slanted # The Bakoma fonts contain many pre-sized alternatives for the This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins