SourceForge logo
SourceForge logo
Menu

matplotlib-checkins

Revision: 4866
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4866&view=rev
Author: mdboom
Date: 2008年01月14日 05:11:16 -0800 (2008年1月14日)
Log Message:
-----------
Fix SVG glyphs for use with Qt (which doesn't look forward for the
glyph definitions).
Modified Paths:
--------------
 branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py	2008年01月12日 13:36:24 UTC (rev 4865)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py	2008年01月14日 13:11:16 UTC (rev 4866)
@@ -284,8 +284,20 @@
 
 fontsize = prop.get_size_in_points()
 color = rgb2hex(gc.get_rgb())
+ write = self._svgwriter.write
 
 if rcParams['svg.embed_char_paths']:
+ new_chars = []
+ for c in s:
+ path = self._add_char_def(prop, c)
+ if path is not None:
+ new_chars.append(path)
+ if len(new_chars):
+ write('<defs>\n')
+ for path in new_chars:
+ write(path)
+ write('</defs>\n')
+
 svg = ['<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))
@@ -297,7 +309,7 @@
 lastgind = None
 currx = 0
 for c in s:
- charid = self._add_char_def(prop, c)
+ charnum = self._get_char_def_id(prop, c)
 ccode = ord(c)
 gind = cmap.get(ccode)
 if gind is None:
@@ -312,7 +324,7 @@
 lastgind = gind
 currx += kern/64.0
 
- svg.append('<use xlink:href="#%s"' % charid)
+ svg.append('<use xlink:href="#%s"' % charnum)
 if currx != 0:
 svg.append(' transform="translate(%s)"' %
 (currx * (self.FONT_SCALE / fontsize)))
@@ -336,7 +348,7 @@
 svg = """\
 <text style="%(style)s" x="%(x)s" y="%(y)s" %(transform)s>%(thetext)s</text>
 """ % locals()
- self._svgwriter.write (svg)
+ write(svg)
 
 def _add_char_def(self, prop, char):
 if isinstance(prop, FontProperties):
@@ -347,9 +359,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)))
- char_num, path = self._char_defs.get(char_id, (None, None))
+ char_num = self._char_defs.get(char_id, None)
 if char_num is not None:
- return char_num
+ return None
 
 path_data = []
 glyph = font.load_char(ord(char), flags=LOAD_NO_HINTING)
@@ -378,9 +390,20 @@
 currx, curry = step[-2], -step[-1]
 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] = char_num
+ return path_element
 
+ def _get_char_def_id(self, prop, char):
+ if isinstance(prop, FontProperties):
+ newprop = prop.copy()
+ font = self._get_font(newprop)
+ else:
+ 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)))
+ return self._char_defs[char_id]
+
 def _draw_mathtext(self, gc, x, y, s, prop, angle):
 """
 Draw math text using matplotlib.mathtext
@@ -390,12 +413,22 @@
 svg_glyphs = svg_elements.svg_glyphs
 svg_rects = svg_elements.svg_rects
 color = rgb2hex(gc.get_rgb())
+ write = self._svgwriter.write
 
- self.open_group("mathtext")
-
 style = "fill: %s" % color
 
 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)
+ if path is not None:
+ new_chars.append(path)
+ if len(new_chars):
+ write('<defs>\n')
+ for path in new_chars:
+ write(path)
+ write('</defs>\n')
+
 svg = ['<g style="%s" transform="' % style]
 if angle != 0:
 svg.append('translate(%s,%s)rotate(%1.1f)'
@@ -405,7 +438,7 @@
 svg.append('">\n')
 
 for font, fontsize, thetext, new_x, new_y_mtc, metrics in svg_glyphs:
- charid = self._add_char_def(font, thetext)
+ charid = self._get_char_def_id(font, thetext)
 
 svg.append('<use xlink:href="#%s" transform="translate(%s,%s)scale(%s)"/>\n' %
 (charid, new_x, -new_y_mtc, fontsize / self.FONT_SCALE))
@@ -459,16 +492,12 @@
 svg.append('<rect x="%s" y="%s" width="%s" height="%s" fill="black" stroke="none" />' % (x, -y + height, width, height))
 svg.append("</g>")
 
- self._svgwriter.write (''.join(svg))
+ self.open_group("mathtext")
+ write (''.join(svg))
 self.close_group("mathtext")
 
 def finish(self):
 write = self._svgwriter.write
- if len(self._char_defs):
- write('<defs id="fontpaths">\n')
- for char_num, path in self._char_defs.values():
- write(path)
- write('</defs>\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.
Revision: 5021
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5021&view=rev
Author: mdboom
Date: 2008年03月26日 07:30:18 -0700 (2008年3月26日)
Log Message:
-----------
Change character ids so they are a hash on the path data itself. (To
fix Kaushik Ghose's copy-and-paste in Inkscape bug).
Modified Paths:
--------------
 branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py	2008年03月24日 12:58:47 UTC (rev 5020)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py	2008年03月26日 14:30:18 UTC (rev 5021)
@@ -1,6 +1,6 @@
 from __future__ import division
 
-import os, codecs, base64, tempfile, urllib, gzip
+import os, codecs, base64, tempfile, urllib, gzip, md5
 
 from matplotlib import agg
 from matplotlib import verbose, __version__, rcParams
@@ -388,8 +388,9 @@
 
 if step[0] != 4:
 currx, curry = step[-2], -step[-1]
- char_num = 'c_%x' % len(self._char_defs)
- path_element = '<path id="%s" d="%s"/>\n' % (char_num, ''.join(path_data))
+ path_data = ''.join(path_data)
+ char_num = 'c_%x' % len(self._char_defs) # md5.new(path_data).hexdigest()
+ path_element = '<symbol id="%s"><path d="%s"/></symbol>\n' % (char_num, ''.join(path_data))
 self._char_defs[char_id] = char_num
 return path_element
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5023
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5023&view=rev
Author: mdboom
Date: 2008年03月26日 07:35:50 -0700 (2008年3月26日)
Log Message:
-----------
Oops in last commit.
Modified Paths:
--------------
 branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py	2008年03月26日 14:33:35 UTC (rev 5022)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py	2008年03月26日 14:35:50 UTC (rev 5023)
@@ -389,7 +389,7 @@
 if step[0] != 4:
 currx, curry = step[-2], -step[-1]
 path_data = ''.join(path_data)
- char_num = 'c_%x' % len(self._char_defs) # md5.new(path_data).hexdigest()
+ char_num = 'c_%s' % md5.new(path_data).hexdigest()
 path_element = '<symbol id="%s"><path d="%s"/></symbol>\n' % (char_num, ''.join(path_data))
 self._char_defs[char_id] = char_num
 return path_element
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5090
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5090&view=rev
Author: mdboom
Date: 2008年04月28日 06:49:50 -0700 (2008年4月28日)
Log Message:
-----------
Oops in last commit -- left in debugging info.
Modified Paths:
--------------
 branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py	2008年04月28日 13:41:28 UTC (rev 5089)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py	2008年04月28日 13:49:50 UTC (rev 5090)
@@ -390,7 +390,6 @@
 currx, curry = step[-2], -step[-1]
 path_data = ''.join(path_data)
 char_num = 'c_%s' % md5.new(path_data).hexdigest()
- char_num = len(self._char_defs)
 path_element = '<path id="%s" d="%s"/>\n' % (char_num, ''.join(path_data))
 self._char_defs[char_id] = char_num
 return path_element
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /