From: <md...@us...> - 2007-07-30 20:45:13
|
Revision: 3637 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3637&view=rev Author: mdboom Date: 2007-07-30 13:45:09 -0700 (Mon, 30 Jul 2007) Log Message: ----------- Fix mathtext bug when svg.embed_char_paths is False Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-07-30 19:46:53 UTC (rev 3636) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-07-30 20:45:09 UTC (rev 3637) @@ -375,7 +375,7 @@ new_y = - new_y_mtc svg.append('<tspan style="font-size: %f; font-family: %s"' % - (fontsize, fontname)) + (fontsize, font.family_name)) xadvance = metrics.advance svg.append(' textLength="%f"' % xadvance) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-06 18:50:03
|
Revision: 3675 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3675&view=rev Author: mdboom Date: 2007-08-06 11:50:00 -0700 (Mon, 06 Aug 2007) Log Message: ----------- Fix bug when rendering special XML characters (such as < > &) in SVG Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-08-06 18:49:19 UTC (rev 3674) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-08-06 18:50:00 UTC (rev 3675) @@ -11,6 +11,8 @@ from matplotlib.ft2font import FT2Font, KERNING_UNFITTED, KERNING_DEFAULT, KERNING_UNSCALED from matplotlib.mathtext import math_parse_s_ft2font_svg +from xml.sax.saxutils import escape as escape_xml_text + backend_version = __version__ def new_figure_manager(num, *args, **kwargs): @@ -239,7 +241,7 @@ font = self._get_font(prop) - thetext = '%s' % s + thetext = escape_xml_text(s) fontfamily = font.family_name fontstyle = font.style_name fontsize = prop.get_size_in_points() @@ -369,10 +371,7 @@ curr_x,curr_y = 0.0,0.0 for font, fontsize, thetext, new_x, new_y_mtc, metrics in svg_glyphs: - if rcParams["mathtext.mathtext2"]: - new_y = new_y_mtc - height - else: - new_y = - new_y_mtc + new_y = - new_y_mtc svg.append('<tspan style="font-size: %f; font-family: %s"' % (fontsize, font.family_name)) @@ -387,6 +386,8 @@ if dy != 0.0: svg.append(' dy="%f"' % dy) + thetext = escape_xml_text(thetext) + svg.append('>%s</tspan>\n' % thetext) curr_x = new_x + xadvance This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-08-07 14:34:25
|
Revision: 3679 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3679&view=rev Author: mdboom Date: 2007-08-07 07:34:24 -0700 (Tue, 07 Aug 2007) Log Message: ----------- Fix character spacing bug in non-mathtext Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-08-07 00:35:08 UTC (rev 3678) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-08-07 14:34:24 UTC (rev 3679) @@ -276,9 +276,9 @@ currx += kern/64.0 svg.append('<use xlink:href="#%s" transform="translate(%s)"/>\n' - % (charid, currx / (fontsize / self.FONT_SCALE))) + % (charid, currx)) - currx += glyph.linearHoriAdvance / 65536.0 + currx += (glyph.linearHoriAdvance / 65536.0) svg.append('</g>\n') svg = ''.join(svg) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-09-05 16:44:34
|
Revision: 3791 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3791&view=rev Author: mdboom Date: 2007-09-05 09:44:31 -0700 (Wed, 05 Sep 2007) Log Message: ----------- Bugfix #1671570: Invalid CSS 2 styles in SVG output Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-09-05 15:47:35 UTC (rev 3790) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-09-05 16:44:31 UTC (rev 3791) @@ -246,7 +246,7 @@ thetext = escape_xml_text(s) fontfamily = font.family_name - fontstyle = font.style_name + fontstyle = prop.get_style() fontsize = prop.get_size_in_points() color = rgb2hex(gc.get_rgb()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-09-07 12:25:40
|
Revision: 3804 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3804&view=rev Author: mdboom Date: 2007-09-07 05:25:37 -0700 (Fri, 07 Sep 2007) Log Message: ----------- Fix a couple of backend_svg buglets. 1. Dashed lines did not render properly 2. Resulting SVG was scaled wrong (width and height should be specified in points, not pixels.) Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-09-07 06:58:00 UTC (rev 3803) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-09-07 12:25:37 UTC (rev 3804) @@ -83,7 +83,7 @@ dashes = '' else: dashes = 'stroke-dasharray: %s; stroke-dashoffset: %f;' % ( - ' '.join(['%f'%val for val in seq]), offset) + ','.join(['%f'%val for val in seq]), offset) linewidth = gc.get_linewidth() if linewidth: @@ -501,7 +501,7 @@ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <!-- Created with matplotlib (http://matplotlib.sourceforge.net/) --> -<svg width="%i" height="%i" viewBox="0 0 %i %i" +<svg width="%ipt" height="%ipt" viewBox="0 0 %i %i" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-09-07 14:34:52
|
Revision: 3807 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3807&view=rev Author: mdboom Date: 2007-09-07 07:34:51 -0700 (Fri, 07 Sep 2007) Log Message: ----------- Backout stylesheet optimization. Breaks on inkscape and Adobe SVG viewer. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-09-07 14:04:36 UTC (rev 3806) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-09-07 14:34:51 UTC (rev 3807) @@ -41,7 +41,6 @@ self._char_defs = {} self.mathtext_parser = MathTextParser('SVG') self.fontd = {} - self._styles = {} svgwriter.write(svgProlog%(width,height,width,height)) def _draw_svg_element(self, element, details, gc, rgbFace): @@ -51,10 +50,9 @@ else: clippath = 'clip-path="url(#%s)"' % clipid - style = self._map_style(self._get_style(gc, rgbFace)) - self._svgwriter.write ('%s<%s class="%s" %s %s/>\n' % ( - cliprect, - element, style, clippath, details)) + style = self._get_style(gc, rgbFace) + self._svgwriter.write ('%s<%s style="%s" %s %s/>\n' % ( + cliprect, element, style, clippath, details)) def _get_font(self, prop): key = hash(prop) @@ -82,13 +80,13 @@ if seq is None: dashes = '' else: - dashes = 'stroke-dasharray: %s; stroke-dashoffset: %f;' % ( - ','.join(['%f'%val for val in seq]), offset) + dashes = 'stroke-dasharray: %s; stroke-dashoffset: %s;' % ( + ','.join(['%s'%val for val in seq]), offset) linewidth = gc.get_linewidth() if linewidth: - return 'fill: %s; stroke: %s; stroke-width: %f; ' \ - 'stroke-linejoin: %s; stroke-linecap: %s; %s opacity: %f' % ( + return 'fill: %s; stroke: %s; stroke-width: %s; ' \ + 'stroke-linejoin: %s; stroke-linecap: %s; %s opacity: %s' % ( fill, rgb2hex(gc.get_rgb()), linewidth, @@ -98,16 +96,11 @@ gc.get_alpha(), ) else: - return 'fill: %s; opacity: %f' % (\ + return 'fill: %s; opacity: %s' % (\ fill, gc.get_alpha(), ) - def _map_style(self, style): - return self._styles.setdefault( - style, - "_%x" % len(self._styles)) - def _get_gc_clip_svg(self, gc): cliprect = gc.get_clip_rectangle() if cliprect is None: @@ -119,12 +112,12 @@ self._clipd[key] = cliprect x, y, w, h = cliprect y = self.height-(y+h) - style = self._map_style("stroke: gray; fill: none;") + style = "stroke: gray; fill: none;" box = """\ <defs> <clipPath id="%(key)s"> - <rect x="%(x)f" y="%(y)f" width="%(w)f" height="%(h)f" - class="%(style)s"/> + <rect x="%(x)s" y="%(y)s" width="%(w)s" height="%(h)s" + style="%(style)s"/> </clipPath> </defs> """ % locals() @@ -144,7 +137,7 @@ """ Ignores angles for now """ - details = 'cx="%f" cy="%f" rx="%f" ry="%f" transform="rotate(%f %f %f)"' % \ + details = 'cx="%s" cy="%s" rx="%s" ry="%s" transform="rotate(%1.1f %s %s)"' % \ (x, self.height-y, width/2.0, height/2.0, -rotation, x, self.height-y) self._draw_svg_element('ellipse', details, gc, rgbFace) @@ -163,7 +156,7 @@ trans[4] += trans[0] trans[5] += trans[3] trans[5] = -trans[5] - transstr = 'transform="matrix(%f %f %f %f %f %f)" '%tuple(trans) + transstr = 'transform="matrix(%s %s %s %s %s %s)" '%tuple(trans) assert trans[1] == 0 assert trans[2] == 0 numrows,numcols = im.get_size() @@ -207,12 +200,12 @@ hrefstr = filename self._svgwriter.write ( - '<image x="%f" y="%f" width="%f" height="%f" ' + '<image x="%s" y="%s" width="%s" height="%s" ' 'xlink:href="%s" %s/>\n'%(x/trans[0], (self.height-y)/trans[3]-h, w, h, hrefstr, transstr) ) def draw_line(self, gc, x1, y1, x2, y2): - details = 'd="M %f,%f L %f,%f"' % (x1, self.height-y1, + details = 'd="M%s,%sL%s,%s"' % (x1, self.height-y1, x2, self.height-y2) self._draw_svg_element('path', details, gc, None) @@ -222,11 +215,11 @@ raise ValueError('x and y must be the same length') y = self.height - y - details = ['d="M %f,%f' % (x[0], y[0])] + details = ['d="M%s,%s' % (x[0], y[0])] xys = zip(x[1:], y[1:]) - details.extend(['L %f,%f' % tup for tup in xys]) + details.extend(['L%s,%s' % tup for tup in xys]) details.append('"') - details = ' '.join(details) + details = ''.join(details) self._draw_svg_element('path', details, gc, None) def draw_point(self, gc, x, y): @@ -234,12 +227,12 @@ self.draw_arc(gc, gc.get_rgb(), x, y, 1, 0, 0, 0, 0) def draw_polygon(self, gc, rgbFace, points): - details = 'points = "%s"' % ' '.join(['%f,%f'%(x,self.height-y) + details = 'points = "%s"' % ' '.join(['%s,%s'%(x,self.height-y) for x, y in points]) self._draw_svg_element('polygon', details, gc, rgbFace) def draw_rectangle(self, gc, rgbFace, x, y, width, height): - details = 'width="%f" height="%f" x="%f" y="%f"' % (width, height, x, + details = 'width="%s" height="%s" x="%s" y="%s"' % (width, height, x, self.height-y-height) self._draw_svg_element('rect', details, gc, rgbFace) @@ -260,12 +253,11 @@ if rcParams['svg.embed_char_paths']: svg = ['<g transform="'] - if angle!=0: - # Inkscape doesn't support rotate(angle x y) - svg.append('translate(%f,%f) rotate(%1.1f) ' % (x,y,-angle)) - else: - svg.append('translate(%f,%f)' % (x,y)) - svg.append(' scale(%f)">\n' % (fontsize / self.FONT_SCALE)) + if angle != 0: + svg.append('translate(%s,%s)rotate(%1.1f)' % (x,y,-angle)) + elif x != 0 or y != 0: + svg.append('translate(%s,%s)' % (x, y)) + svg.append('scale(%s)">\n' % (fontsize / self.FONT_SCALE)) cmap = font.get_charmap() lastgind = None @@ -286,21 +278,24 @@ lastgind = gind currx += kern/64.0 - svg.append('<use xlink:href="#%s" transform="translate(%s)"/>\n' - % (charid, currx * (self.FONT_SCALE / fontsize))) - + svg.append('<use xlink:href="#%s"' % charid) + if currx != 0: + svg.append(' transform="translate(%s)"' % + (currx * (self.FONT_SCALE / fontsize))) + svg.append('/>\n') currx += (glyph.linearHoriAdvance / 65536.0) svg.append('</g>\n') svg = ''.join(svg) else: style = 'font-size: %f; font-family: %s; font-style: %s; fill: %s;'%(fontsize, fontfamily,fontstyle, color) - style_number = self._map_style(style) if angle!=0: - transform = 'transform="translate(%f,%f) rotate(%1.1f) translate(%f,%f)"' % (x,y,-angle,-x,-y) # Inkscape doesn't support rotate(angle x y) - else: transform = '' + transform = 'transform="translate(%s,%s) rotate(%1.1f) translate(%s,%s)"' % (x,y,-angle,-x,-y) + # Inkscape doesn't support rotate(angle x y) + else: + transform = '' svg = """\ -<text class="%(style_number)s" x="%(x)f" y="%(y)f" %(transform)s>%(thetext)s</text> +<text style="%(style)s" x="%(x)s" y="%(y)s" %(transform)s>%(thetext)s</text> """ % locals() self._svgwriter.write (svg) @@ -313,8 +308,9 @@ 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))) - if char_id in self._char_defs: - return char_id + char_num, path = self._char_defs.get(char_id, (None, None)) + if char_num is not None: + return char_num path_data = [] glyph = font.load_char(ord(char), flags=LOAD_NO_HINTING) @@ -340,11 +336,11 @@ if step[0] != 4: currx, curry = step[-2], -step[-1] - path_element = '<path id="%s" d="%s"/>\n' % (char_id, " ".join(path_data)) + char_num = 'c_%x' % len(self._char_defs) + path_element = '<path id="%s" d="%s"/>\n' % (char_num, ''.join(path_data)) + self._char_defs[char_id] = (char_num, path_element) + return char_num - self._char_defs[char_id] = path_element - return char_id - def _draw_mathtext(self, gc, x, y, s, prop, angle): """ Draw math text using matplotlib.mathtext @@ -358,25 +354,24 @@ self.open_group("mathtext") style = "fill: %s" % color - style_number = self._map_style(style) if rcParams['svg.embed_char_paths']: - svg = ['<g class="%s" transform="' % style_number] + svg = ['<g style="%s" transform="' % style] if angle != 0: - svg.append('translate(%f,%f) rotate(%1.1f)' + svg.append('translate(%s,%s)rotate(%1.1f)' % (x,y,-angle) ) else: - svg.append('translate(%f,%f)' % (x, y)) + svg.append('translate(%s,%s)' % (x, y)) svg.append('">\n') for font, fontsize, thetext, new_x, new_y_mtc, metrics in svg_glyphs: charid = self._add_char_def(font, thetext) - svg.append('<use xlink:href="#%s" transform="translate(%s, %s) scale(%s)"/>\n' % + svg.append('<use xlink:href="#%s" transform="translate(%s,%s)scale(%s)"/>\n' % (charid, new_x, -new_y_mtc, fontsize / self.FONT_SCALE)) svg.append('</g>\n') else: # not rcParams['svg.embed_char_paths'] - svg = ['<text class="%s" x="%f" y="%f"' % (style_number, x, y)] + svg = ['<text style="%s" x="%f" y="%f"' % (style, x, y)] if angle != 0: svg.append(' transform="translate(%f,%f) rotate(%1.1f) translate(%f,%f)"' @@ -388,19 +383,18 @@ for font, fontsize, thetext, new_x, new_y_mtc, metrics in svg_glyphs: new_y = - new_y_mtc style = "font-size: %f; font-family: %s" % (fontsize, font.family_name) - style_number = self._map_style(style) - svg.append('<tspan class="%s"' % style_number) + svg.append('<tspan style="%s"' % style) xadvance = metrics.advance - svg.append(' textLength="%f"' % xadvance) + svg.append(' textLength="%s"' % xadvance) dx = new_x - curr_x if dx != 0.0: - svg.append(' dx="%f"' % dx) + svg.append(' dx="%s"' % dx) dy = new_y - curr_y if dy != 0.0: - svg.append(' dy="%f"' % dy) + svg.append(' dy="%s"' % dy) thetext = escape_xml_text(thetext) @@ -412,13 +406,13 @@ svg.append('</text>\n') if len(svg_rects): - style_number = self._map_style("fill: black; stroke: none") - svg.append('<g class="%s" transform="' % style_number) + style = "fill: black; stroke: none" + svg.append('<g style="%s" transform="' % style) if angle != 0: - svg.append('translate(%f,%f) rotate(%1.1f)' + svg.append('translate(%s,%s) rotate(%1.1f)' % (x,y,-angle) ) else: - svg.append('translate(%f,%f)' % (x, y)) + svg.append('translate(%s,%s)' % (x, y)) svg.append('">\n') for x, y, width, height in svg_rects: @@ -432,16 +426,9 @@ write = self._svgwriter.write if len(self._char_defs): write('<defs id="fontpaths">\n') - for path in self._char_defs.values(): + for char_num, path in self._char_defs.values(): write(path) write('</defs>\n') - if len(self._styles): - write('<style type="text/css">\n') - styles = self._styles.items() - styles.sort() - for style, number in styles: - write('.%s { %s }\n' % (number, style)) - write('</style>\n') write('</svg>\n') def flipy(self): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-09-07 14:55:58
|
Revision: 3808 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3808&view=rev Author: mdboom Date: 2007-09-07 07:55:55 -0700 (Fri, 07 Sep 2007) Log Message: ----------- Fix embedded glyph rendering bug revealed by Inkscape and Safari (but not Firefox) Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-09-07 14:34:51 UTC (rev 3807) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-09-07 14:55:55 UTC (rev 3808) @@ -317,8 +317,8 @@ currx, curry = 0.0, 0.0 for step in glyph.path: if step[0] == 0: # MOVE_TO - path_data.append("m%s %s" % - (step[1] - currx, -step[2] - curry)) + path_data.append("M%s %s" % + (step[1], -step[2])) elif step[0] == 1: # LINE_TO path_data.append("l%s %s" % (step[1] - currx, -step[2] - curry)) @@ -332,7 +332,8 @@ step[3] - currx, -step[4] - curry, step[5] - currx, -step[6] - curry)) elif step[0] == 4: # ENDPOLY - path_data.append("Z") + path_data.append("z") + currx, curry = 0.0, 0.0 if step[0] != 4: currx, curry = step[-2], -step[-1] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-12 19:22:09
|
Revision: 4235 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4235&view=rev Author: mdboom Date: 2007-11-12 11:22:05 -0800 (Mon, 12 Nov 2007) Log Message: ----------- [ 1545149 ] Problem rendering image in SVG backend Reading the image file should use binary mode. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-11-12 19:15:28 UTC (rev 4234) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-11-12 19:22:05 UTC (rev 4235) @@ -184,7 +184,7 @@ im.write_png(filename) im.flipud_out() - imfile = file (filename, 'r') + imfile = file (filename, 'rb') image64 = base64.encodestring (imfile.read()) imfile.close() os.remove(filename) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-26 15:31:58
|
Revision: 4441 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4441&view=rev Author: mdboom Date: 2007-11-26 07:31:54 -0800 (Mon, 26 Nov 2007) Log Message: ----------- Fix colored text in SVG backend. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-11-26 15:30:12 UTC (rev 4440) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-11-26 15:31:54 UTC (rev 4441) @@ -246,14 +246,11 @@ font.set_text(s, 0.0, flags=LOAD_NO_HINTING) y -= font.get_descent() / 64.0 - thetext = escape_xml_text(s) - fontfamily = font.family_name - fontstyle = prop.get_style() fontsize = prop.get_size_in_points() color = rgb2hex(gc.get_rgb()) if rcParams['svg.embed_char_paths']: - svg = ['<g transform="'] + svg = ['<g style="fill: %s" transform="' % color] if angle != 0: svg.append('translate(%s,%s)rotate(%1.1f)' % (x,y,-angle)) elif x != 0 or y != 0: @@ -288,6 +285,10 @@ svg.append('</g>\n') svg = ''.join(svg) else: + thetext = escape_xml_text(s) + fontfamily = font.family_name + fontstyle = prop.get_style() + style = 'font-size: %f; font-family: %s; font-style: %s; fill: %s;'%(fontsize, fontfamily,fontstyle, color) if angle!=0: transform = 'transform="translate(%s,%s) rotate(%1.1f) translate(%s,%s)"' % (x,y,-angle,-x,-y) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-26 15:42:12
|
Revision: 4442 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4442&view=rev Author: mdboom Date: 2007-11-26 07:42:10 -0800 (Mon, 26 Nov 2007) Log Message: ----------- Reduce SVG file sizes. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-11-26 15:31:54 UTC (rev 4441) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-11-26 15:42:10 UTC (rev 4442) @@ -26,7 +26,7 @@ _capstyle_d = {'projecting' : 'square', 'butt' : 'butt', 'round': 'round',} class RendererSVG(RendererBase): - FONT_SCALE = 1200.0 + FONT_SCALE = 100.0 def __init__(self, width, height, svgwriter, basename=None): self.width=width This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-26 15:43:31
|
Revision: 4443 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4443&view=rev Author: mdboom Date: 2007-11-26 07:43:26 -0800 (Mon, 26 Nov 2007) Log Message: ----------- One more SVG color detail (in mathtext) Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-11-26 15:42:10 UTC (rev 4442) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-11-26 15:43:26 UTC (rev 4443) @@ -409,7 +409,7 @@ svg.append('</text>\n') if len(svg_rects): - style = "fill: black; stroke: none" + style = "fill: %s; stroke: none" % color svg.append('<g style="%s" transform="' % style) if angle != 0: svg.append('translate(%s,%s) rotate(%1.1f)' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2008-05-08 16:50:02
|
Revision: 5131 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5131&view=rev Author: mdboom Date: 2008-05-08 09:49:50 -0700 (Thu, 08 May 2008) Log Message: ----------- A number of SVG improvements: Clipping in markers, collections and text. Text kerning with embedded fonts. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-05-08 16:45:55 UTC (rev 5130) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-05-08 16:49:50 UTC (rev 5131) @@ -193,11 +193,20 @@ write('<defs><path id="%s" d="%s"/></defs>\n' % (name, key)) self._markers[key] = name + clipid = self._get_gc_clip_svg(gc) + if clipid is None: + clippath = '' + else: + clippath = 'clip-path="url(#%s)"' % clipid + + write('<g %s>' % clippath) trans_and_flip = self._make_flip_transform(trans) tpath = trans_and_flip.transform_path(path) for x, y in tpath.vertices: details = 'xlink:href="#%s" x="%f" y="%f"' % (name, x, y) - self._draw_svg_element('use', details, gc, rgbFace) + style = self._get_style(gc, rgbFace) + self._svgwriter.write ('<use style="%s" %s/>\n' % (style, details)) + write('</g>') def draw_path_collection(self, master_transform, cliprect, clippath, clippath_trans, paths, all_transforms, offsets, @@ -221,8 +230,14 @@ path_codes, cliprect, clippath, clippath_trans, offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds): + clipid = self._get_gc_clip_svg(gc) + if clipid is not None: + write('<g clip-path="url(#%s)">' % clipid) details = 'xlink:href="#%s" x="%f" y="%f"' % (path_id, xo, self.height - yo) - self._draw_svg_element('use', details, gc, rgbFace) + style = self._get_style(gc, rgbFace) + self._svgwriter.write ('<use style="%s" %s/>\n' % (style, details)) + if clipid is not None: + write('</g>') self._path_collection_id += 1 @@ -309,7 +324,12 @@ write(path) write('</defs>\n') - svg = ['<g style="fill: %s; opacity: %s" transform="' % (color, gc.get_alpha())] + svg = [] + clipid = self._get_gc_clip_svg(gc) + if clipid is not None: + svg.append('<g clip-path="url(#%s)">\n' % clipid) + + svg.append('<g style="fill: %s; opacity: %s" transform="' % (color, gc.get_alpha())) if angle != 0: svg.append('translate(%s,%s)rotate(%1.1f)' % (x,y,-angle)) elif x != 0 or y != 0: @@ -332,16 +352,19 @@ kern = font.get_kerning(lastgind, gind, KERNING_DEFAULT) else: kern = 0 - lastgind = gind - currx += kern/64.0 + currx += (kern / 64.0) / (self.FONT_SCALE / fontsize) svg.append('<use xlink:href="#%s"' % charnum) if currx != 0: svg.append(' x="%s"' % (currx * (self.FONT_SCALE / fontsize))) svg.append('/>\n') + currx += (glyph.linearHoriAdvance / 65536.0) / (self.FONT_SCALE / fontsize) + lastgind = gind svg.append('</g>\n') + if clipid is not None: + svg.append('</g>\n') svg = ''.join(svg) else: thetext = escape_xml_text(s) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |