@@ -398,11 +398,15 @@ def _get_clip_path(self, clippath, clippath_transform):
398398 pid = self ._clip_paths .get (key )
399399 if pid is None :
400400 pid = 'c%x' % len (self ._clip_paths )
401- ps_cmd = ['/%s {' % pid ]
402- ps_cmd .append (self ._convert_path (clippath , clippath_transform ,
403- simplify = False ))
404- ps_cmd .extend (['clip' , 'newpath' , '} bind def\n ' ])
405- self ._pswriter .write ('\n ' .join (ps_cmd ))
401+ clippath_bytes = self ._convert_path (
402+ clippath , clippath_transform , simplify = False )
403+ self ._pswriter .write (f"""\
404+ /{ pid } {{
405+ { clippath_bytes }
406+ clip
407+ newpath
408+ }} bind def
409+ """ )
406410 self ._clip_paths [key ] = pid
407411 return pid
408412
@@ -497,11 +501,14 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
497501 for i , (path , transform ) in enumerate (self ._iter_collection_raw_paths (
498502 master_transform , paths , all_transforms )):
499503 name = 'p%x_%x' % (self ._path_collection_id , i )
500- ps_cmd = ['/%s {' % name ,
501- 'newpath' , 'translate' ]
502- ps_cmd .append (self ._convert_path (path , transform , simplify = False ))
503- ps_cmd .extend (['} bind def\n ' ])
504- write ('\n ' .join (ps_cmd ))
504+ path_bytes = self ._convert_path (path , transform , simplify = False )
505+ write (f"""\
506+ /{ name } {{
507+ newpath
508+ translate
509+ { path_bytes }
510+ }} bind def
511+ """ )
505512 path_codes .append (name )
506513
507514 for xo , yo , path_id , gc0 , rgbFace in self ._iter_collection (
0 commit comments