@@ -1082,10 +1082,12 @@ def print_figure_impl(fh):
1082
1082
if isEPSF :
1083
1083
print ("%!PS-Adobe-3.0 EPSF-3.0" , file = fh )
1084
1084
else :
1085
- print ("%!PS-Adobe-3.0" , file = fh )
1085
+ print ("%!PS-Adobe-3.0\n "
1086
+ "%%DocumentPaperSizes: {papertype}\n "
1087
+ "%%Pages: 1\n " .format (papertype = papertype ),
1088
+ end = "" , file = fh )
1086
1089
if title :
1087
1090
print ("%%Title: " + title , file = fh )
1088
- print ("%%Creator: " + creator_str , file = fh )
1089
1091
# get source date from SOURCE_DATE_EPOCH, if set
1090
1092
# See https://reproducible-builds.org/specs/source-date-epoch/
1091
1093
source_date_epoch = os .getenv ("SOURCE_DATE_EPOCH" )
@@ -1094,14 +1096,14 @@ def print_figure_impl(fh):
1094
1096
int (source_date_epoch )).strftime ("%a %b %d %H:%M:%S %Y" )
1095
1097
else :
1096
1098
source_date = time .ctime ()
1097
- print ("%%CreationDate: " + source_date , file = fh )
1098
- print ( "%%Orientation: " + orientation , file = fh )
1099
- if not isEPSF :
1100
- print ( "%%DocumentPaperSizes: " + papertype , file = fh )
1101
- print ( "%%%%BoundingBox: %d %d %d %d" % bbox , file = fh )
1102
- if not isEPSF :
1103
- print ( "%%Pages: 1" , file = fh )
1104
- print ( "%%EndComments " , file = fh )
1099
+ print ("%%Creator: {creator_str} \n "
1100
+ "%%CreationDate: {source_date} \n "
1101
+ "%%Orientation: {orientation} \n "
1102
+ "%%BoundingBox: {bbox[0]} {bbox[1]} {bbox[2]} {bbox[3]} \n "
1103
+ "%%EndComments \n "
1104
+ . format ( creator_str = creator_str , source_date = source_date ,
1105
+ orientation = orientation , bbox = bbox ),
1106
+ end = " " , file = fh )
1105
1107
1106
1108
Ndict = len (psDefs )
1107
1109
print ("%%BeginProlog" , file = fh )
@@ -1278,7 +1280,6 @@ def write(self, *kl, **kwargs):
1278
1280
print ("%!PS-Adobe-3.0 EPSF-3.0" , file = fh )
1279
1281
if title :
1280
1282
print ("%%Title: " + title , file = fh )
1281
- print ("%%Creator: " + creator_str , file = fh )
1282
1283
# get source date from SOURCE_DATE_EPOCH, if set
1283
1284
# See https://reproducible-builds.org/specs/source-date-epoch/
1284
1285
source_date_epoch = os .getenv ("SOURCE_DATE_EPOCH" )
@@ -1288,20 +1289,24 @@ def write(self, *kl, **kwargs):
1288
1289
"%a %b %d %H:%M:%S %Y" )
1289
1290
else :
1290
1291
source_date = time .ctime ()
1291
- print ("%%CreationDate: " + source_date , file = fh )
1292
- print ("%%%%BoundingBox: %d %d %d %d" % bbox , file = fh )
1293
- print ("%%EndComments" , file = fh )
1294
-
1295
- Ndict = len (psDefs )
1296
- print ("%%BeginProlog" , file = fh )
1297
- print ("/mpldict %d dict def" % Ndict , file = fh )
1298
- print ("mpldict begin" , file = fh )
1299
- for d in psDefs :
1300
- d = d .strip ()
1301
- for l in d .split ('\n ' ):
1302
- print (l .strip (), file = fh )
1303
- print ("end" , file = fh )
1304
- print ("%%EndProlog" , file = fh )
1292
+ print (
1293
+ "%%Creator: {creator_str}\n "
1294
+ "%%CreationDate: {source_date}\n "
1295
+ "%%BoundingBox: {bbox[0]} {bbox[1]} {bbox[2]} {bbox[3]}\n "
1296
+ "%%EndComments\n "
1297
+ .format (creator_str = creator_str , source_date = source_date ,
1298
+ bbox = bbox ),
1299
+ end = "" , file = fh )
1300
+
1301
+ print ("%%BeginProlog\n "
1302
+ "/mpldict {len_psDefs} dict def\n "
1303
+ "mpldict begin\n "
1304
+ "{psDefs}\n "
1305
+ "end\n "
1306
+ "%%EndProlog\n "
1307
+ .format (len_psDefs = len (psDefs ),
1308
+ psDefs = "\n " .join (psDefs )),
1309
+ end = "" , file = fh )
1305
1310
1306
1311
print ("mpldict begin" , file = fh )
1307
1312
print ("%s translate" % _nums_to_str (xo , yo ), file = fh )
0 commit comments