@@ -1109,26 +1109,28 @@ def writeImages(self):
11091109
11101110 def markerObject (self , path , trans , fillp , lw ):
11111111 """Return name of a marker XObject representing the given path."""
1112- key = (path , trans , fillp is not None , lw )
1112+ pathops = self .pathOperations (path , trans )
1113+ key = (tuple (pathops ), bool (fillp ))
11131114 result = self .markers .get (key )
11141115 if result is None :
11151116 name = Name ('M%d' % len (self .markers ))
11161117 ob = self .reserveObject ('marker %d' % len (self .markers ))
1117- self .markers [key ] = (name , ob , path , trans , fillp , lw )
1118+ bbox = path .get_extents (trans )
1119+ self .markers [key ] = [name , ob , bbox , lw ]
11181120 else :
1121+ if result [- 1 ] < lw :
1122+ result [- 1 ] = lw
11191123 name = result [0 ]
11201124 return name
11211125
11221126 def writeMarkers (self ):
1123- for tup in self .markers .values ():
1124- name , object , path , trans , fillp , lw = tup
1125- bbox = path .get_extents (trans )
1127+ for (pathops , fillp ),(name , ob , bbox , lw ) in self .markers .iteritems ():
11261128 bbox = bbox .padded (lw * 0.5 )
11271129 self .beginStream (
1128- object .id , None ,
1130+ ob .id , None ,
11291131 {'Type' : Name ('XObject' ), 'Subtype' : Name ('Form' ),
11301132 'BBox' : list (bbox .extents ) })
1131- self .writePath ( path , trans )
1133+ self .output ( * pathops )
11321134 if fillp :
11331135 self .output (Op .fill_stroke )
11341136 else :
@@ -1280,10 +1282,17 @@ def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
12801282
12811283 def draw_path (self , gc , path , transform , rgbFace = None ):
12821284 self .check_gc (gc , rgbFace )
1283- stream = self .file .writePath (path , transform , rgbFace is None )
1285+ self .file .writePath (path , transform , rgbFace is None )
12841286 self .file .output (self .gc .paint ())
12851287
12861288 def draw_markers (self , gc , marker_path , marker_trans , path , trans , rgbFace = None ):
1289+ # For simple paths or small numbers of markers, don't bother
1290+ # making an XObject
1291+ if len (path ) * len (marker_path ) <= 10 :
1292+ RendererBase .draw_markers (self , gc , marker_path , marker_trans ,
1293+ path , trans , rgbFace )
1294+ return
1295+
12871296 self .check_gc (gc , rgbFace )
12881297 fillp = rgbFace is not None
12891298
0 commit comments