[reportlab-users] problem with renderSVG
Dirk Datzert
reportlab-users@reportlab.com
Tue, 07 Oct 2003 21:23:09 +0200
Dies ist eine mehrteilige Nachricht im MIME-Format.
--------------2C2DCF3E64343ECA8BA9F740
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi Dinu,
I think that I found the problem: the state variables of the
self._canvas object are restore via _restores, but the corresponding
self._canvas.style is not restored after a state change.
With the patch attached self._canvas.style is restored at same time as
the state variables ar restored.
Regards,
Dirk
--------------2C2DCF3E64343ECA8BA9F740
Content-Type: text/plain; charset=us-ascii;
name="renderSVG.py.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="renderSVG.py.patch"
--- renderSVG.py.orig Fri Sep 26 20:59:52 2003
+++ renderSVG.py Tue Oct 7 19:18:47 2003
@@ -515,6 +515,7 @@
if self._strokeColor != None:
self.setColor(self._strokeColor)
+ self.setFillColor(None)
pairs = []
for i in xrange(len(points)):
pairs.append("%f %f" % (points[i]))
@@ -631,34 +632,21 @@
self._canvas.comment('begin node %s'%`node`)
color = self._canvas._color
- if not (isinstance(node, Path) and node.isClipPath):
- pass # self._canvas.saveState()
#apply state changes
- deltas = getStateDelta(node)
- self._tracker.push(deltas)
- self.applyStateChanges(deltas, {})
+ self.push(node)
#draw the object, or recurse
self.drawNodeDispatcher(node)
- rDeltas = self._tracker.pop()
- if not (isinstance(node, Path) and node.isClipPath):
- pass # self._canvas.restoreState()
+ # restore the state
+ self.pop()
+
self._canvas.comment('end node %s'%`node`)
self._canvas._color = color
- #restore things we might have lost (without actually doing anything).
- for k, v in rDeltas.items():
- if self._restores.has_key(k):
- setattr(self._canvas,self._restores[k],v)
-
if self.verbose: print "### end _SVGRenderer.drawNode"
- _restores = {'strokeColor':'_strokeColor','strokeWidth': '_lineWidth','strokeLineCap':'_lineCap',
- 'strokeLineJoin':'_lineJoin','fillColor':'_fillColor','fontName':'_font',
- 'fontSize':'_fontSize'}
-
def drawGroup(self, group):
if self.verbose: print "### begin _SVGRenderer.drawGroup"
@@ -756,6 +744,18 @@
c._fillColor = None
c._fillAndStroke([], clip=path.isClipPath)
+ def pop(self):
+ self._tracker.pop()
+ self.applyState()
+
+ def push(self,node):
+ deltas = getStateDelta(node)
+ self._tracker.push(deltas)
+ self.applyState()
+
+ def applyState(self):
+ s = self._tracker.getState()
+ self.applyStateChanges(s, {})
def applyStateChanges(self, delta, newState):
"""This takes a set of states, and outputs the operators
--------------2C2DCF3E64343ECA8BA9F740--