From: <md...@us...> - 2011-02-17 15:51:23
|
Revision: 8986 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8986&view=rev Author: mdboom Date: 2011-02-17 15:51:17 +0000 (Thu, 17 Feb 2011) Log Message: ----------- Fix long Unicode characters in SVG backend (fixes mathtext_stixsans test on narrow Python builds.) Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py trunk/matplotlib/lib/matplotlib/mathtext.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2011-02-17 15:50:47 UTC (rev 8985) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2011-02-17 15:51:17 UTC (rev 8986) @@ -603,7 +603,7 @@ if rcParams['svg.embed_char_paths']: new_chars = [] for c in s: - path = self._add_char_def(prop, c) + path = self._add_char_def(prop, ord(c)) if path is not None: new_chars.append(path) if len(new_chars): @@ -628,7 +628,7 @@ lastgind = None currx = 0 for c in s: - charnum = self._get_char_def_id(prop, c) + charnum = self._get_char_def_id(prop, ord(c)) ccode = ord(c) gind = cmap.get(ccode) if gind is None: @@ -680,13 +680,13 @@ font = prop font.set_size(self.FONT_SCALE, 72) ps_name = font.get_sfnt()[(1,0,0,6)] - char_id = urllib.quote('%s-%d' % (ps_name, ord(char))) + char_id = urllib.quote('%s-%d' % (ps_name, char)) char_num = self._char_defs.get(char_id, None) if char_num is not None: return None path_data = [] - glyph = font.load_char(ord(char), flags=LOAD_NO_HINTING) + glyph = font.load_char(char, flags=LOAD_NO_HINTING) currx, curry = 0.0, 0.0 for step in glyph.path: if step[0] == 0: # MOVE_TO @@ -724,7 +724,7 @@ font = prop font.set_size(self.FONT_SCALE, 72) ps_name = font.get_sfnt()[(1,0,0,6)] - char_id = urllib.quote('%s-%d' % (ps_name, ord(char))) + char_id = urllib.quote('%s-%d' % (ps_name, char)) return self._char_defs[char_id] def _draw_mathtext(self, gc, x, y, s, prop, angle): @@ -742,8 +742,8 @@ if rcParams['svg.embed_char_paths']: new_chars = [] - for font, fontsize, thetext, new_x, new_y_mtc, metrics in svg_glyphs: - path = self._add_char_def(font, thetext) + for font, fontsize, char, new_x, new_y_mtc, metrics in svg_glyphs: + path = self._add_char_def(font, char) if path is not None: new_chars.append(path) if len(new_chars): @@ -760,8 +760,8 @@ svg.append('translate(%f,%f)' % (x, y)) svg.append('">\n') - for font, fontsize, thetext, new_x, new_y_mtc, metrics in svg_glyphs: - charid = self._get_char_def_id(font, thetext) + for font, fontsize, char, new_x, new_y_mtc, metrics in svg_glyphs: + charid = self._get_char_def_id(font, char) svg.append('<use xlink:href="#%s" transform="translate(%f,%f)scale(%f)"/>\n' % (charid, new_x, -new_y_mtc, fontsize / self.FONT_SCALE)) Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2011-02-17 15:50:47 UTC (rev 8985) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2011-02-17 15:51:17 UTC (rev 8986) @@ -329,10 +329,9 @@ def render_glyph(self, ox, oy, info): oy = self.height - oy + info.offset - thetext = unichr_safe(info.num) self.svg_glyphs.append( - (info.font, info.fontsize, thetext, ox, oy, info.metrics)) + (info.font, info.fontsize, info.num, ox, oy, info.metrics)) def render_rect_filled(self, x1, y1, x2, y2): self.svg_rects.append( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |