@@ -1068,39 +1068,46 @@ def write(self, *kl, **kwargs):
1068
1068
else :
1069
1069
creator_str = "matplotlib version " + __version__ + \
1070
1070
", http://matplotlib.org/"
1071
+
1071
1072
def print_figure_impl ():
1072
1073
# write the PostScript headers
1073
- if isEPSF : print ("%!PS-Adobe-3.0 EPSF-3.0" , file = fh )
1074
- else : print ("%!PS-Adobe-3.0" , file = fh )
1075
- if title : print ("%%Title: " + title , file = fh )
1074
+ if isEPSF :
1075
+ print ("%!PS-Adobe-3.0 EPSF-3.0" , file = fh )
1076
+ else :
1077
+ print ("%!PS-Adobe-3.0" , file = fh )
1078
+ if title :
1079
+ print ("%%Title: " + title , file = fh )
1076
1080
print ("%%Creator: " + creator_str , file = fh )
1077
1081
# get source date from SOURCE_DATE_EPOCH, if set
1078
1082
# See https://reproducible-builds.org/specs/source-date-epoch/
1079
1083
source_date_epoch = os .getenv ("SOURCE_DATE_EPOCH" )
1080
1084
if source_date_epoch :
1081
1085
source_date = datetime .datetime .utcfromtimestamp (
1082
- int (source_date_epoch ) ).strftime ("%a %b %d %H:%M:%S %Y" )
1086
+ int (source_date_epoch )).strftime ("%a %b %d %H:%M:%S %Y" )
1083
1087
else :
1084
1088
source_date = time .ctime ()
1085
1089
print ("%%CreationDate: " + source_date , file = fh )
1086
1090
print ("%%Orientation: " + orientation , file = fh )
1087
- if not isEPSF : print ("%%DocumentPaperSizes: " + papertype , file = fh )
1091
+ if not isEPSF :
1092
+ print ("%%DocumentPaperSizes: " + papertype , file = fh )
1088
1093
print ("%%%%BoundingBox: %d %d %d %d" % bbox , file = fh )
1089
- if not isEPSF : print ("%%Pages: 1" , file = fh )
1094
+ if not isEPSF :
1095
+ print ("%%Pages: 1" , file = fh )
1090
1096
print ("%%EndComments" , file = fh )
1091
1097
1092
1098
Ndict = len (psDefs )
1093
1099
print ("%%BeginProlog" , file = fh )
1094
1100
if not rcParams ['ps.useafm' ]:
1095
1101
Ndict += len (ps_renderer .used_characters )
1096
- print ("/mpldict %d dict def" % Ndict , file = fh )
1102
+ print ("/mpldict %d dict def" % Ndict , file = fh )
1097
1103
print ("mpldict begin" , file = fh )
1098
1104
for d in psDefs :
1099
- d = d .strip ()
1105
+ d = d .strip ()
1100
1106
for l in d .split ('\n ' ):
1101
1107
print (l .strip (), file = fh )
1102
1108
if not rcParams ['ps.useafm' ]:
1103
- for font_filename , chars in six .itervalues (ps_renderer .used_characters ):
1109
+ for font_filename , chars in six .itervalues (
1110
+ ps_renderer .used_characters ):
1104
1111
if len (chars ):
1105
1112
font = get_font (font_filename )
1106
1113
glyph_ids = []
@@ -1120,21 +1127,29 @@ def print_figure_impl():
1120
1127
# STIX fonts). This will simply turn that off to avoid
1121
1128
# errors.
1122
1129
if is_opentype_cff_font (font_filename ):
1123
- raise RuntimeError ("OpenType CFF fonts can not be saved using the internal Postscript backend at this time.\n Consider using the Cairo backend." )
1130
+ msg = ("OpenType CFF fonts can not be saved "
1131
+ "using the internal Postscript backend "
1132
+ "at this time.\n Consider using the "
1133
+ "Cairo backend." )
1134
+ raise RuntimeError (msg )
1124
1135
else :
1125
1136
fh .flush ()
1126
1137
convert_ttf_to_ps (
1127
- font_filename .encode (sys .getfilesystemencoding ()),
1138
+ font_filename .encode (
1139
+ sys .getfilesystemencoding ()),
1128
1140
fh , fonttype , glyph_ids )
1129
1141
print ("end" , file = fh )
1130
1142
print ("%%EndProlog" , file = fh )
1131
1143
1132
- if not isEPSF : print ("%%Page: 1 1" , file = fh )
1144
+ if not isEPSF :
1145
+ print ("%%Page: 1 1" , file = fh )
1133
1146
print ("mpldict begin" , file = fh )
1134
- #print >>fh, "gsave"
1135
- print ("%s translate" % _nums_to_str (xo , yo ), file = fh )
1136
- if rotation : print ("%d rotate" % rotation , file = fh )
1137
- print ("%s clipbox" % _nums_to_str (width * 72 , height * 72 , 0 , 0 ), file = fh )
1147
+
1148
+ print ("%s translate" % _nums_to_str (xo , yo ), file = fh )
1149
+ if rotation :
1150
+ print ("%d rotate" % rotation , file = fh )
1151
+ print ("%s clipbox" % _nums_to_str (width * 72 , height * 72 , 0 , 0 ),
1152
+ file = fh )
1138
1153
1139
1154
# write the figure
1140
1155
content = self ._pswriter .getvalue ()
@@ -1143,10 +1158,10 @@ def print_figure_impl():
1143
1158
print (content , file = fh )
1144
1159
1145
1160
# write the trailer
1146
- #print >>fh, "grestore"
1147
1161
print ("end" , file = fh )
1148
1162
print ("showpage" , file = fh )
1149
- if not isEPSF : print ("%%EOF" , file = fh )
1163
+ if not isEPSF :
1164
+ print ("%%EOF" , file = fh )
1150
1165
fh .flush ()
1151
1166
1152
1167
if rcParams ['ps.usedistiller' ]:
@@ -1161,8 +1176,9 @@ def print_figure_impl():
1161
1176
requires_unicode = file_requires_unicode (outfile )
1162
1177
1163
1178
if (not requires_unicode and
1164
- (six .PY3 or not isinstance (outfile , StringIO ))):
1179
+ (six .PY3 or not isinstance (outfile , StringIO ))):
1165
1180
fh = io .TextIOWrapper (outfile , encoding = "latin-1" )
1181
+
1166
1182
# Prevent the io.TextIOWrapper from closing the
1167
1183
# underlying file
1168
1184
def do_nothing ():
0 commit comments