Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions lib/matplotlib/_type1font.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,7 @@ def _read(self, file):
elif type == 3: # end of file
break
else:
raise RuntimeError('Unknown segment type %d in pfb file' %
type)
raise RuntimeError('Unknown segment type %d in pfb file' % type)

return data

Expand Down Expand Up @@ -725,7 +724,7 @@ def transform(self, effects):

if 'slant' in effects:
slant = effects['slant']
fontname += '_Slant_%d' % int(1000 * slant)
fontname += f'_Slant_{int(1000 * slant)}'
italicangle = round(
float(italicangle) - np.arctan(slant) / np.pi * 180,
5
Expand All @@ -734,21 +733,21 @@ def transform(self, effects):

if 'extend' in effects:
extend = effects['extend']
fontname += '_Extend_%d' % int(1000 * extend)
fontname += f'_Extend_{int(1000 * extend)}'
modifier[0, 0] = extend

newmatrix = np.dot(modifier, oldmatrix)
array[::2] = newmatrix[0:3, 0]
array[1::2] = newmatrix[0:3, 1]
fontmatrix = (
'[%s]' % ' '.join(_format_approx(x, 6) for x in array)
f"[{' '.join(_format_approx(x, 6) for x in array)}]"
)
replacements = (
[(x, '/FontName/%s def' % fontname)
[(x, f'/FontName/{fontname} def')
for x in self._pos['FontName']]
+ [(x, '/ItalicAngle %a def' % italicangle)
+ [(x, f'/ItalicAngle {italicangle} def')
for x in self._pos['ItalicAngle']]
+ [(x, '/FontMatrix %s readonly def' % fontmatrix)
+ [(x, f'/FontMatrix {fontmatrix} readonly def')
for x in self._pos['FontMatrix']]
+ [(x, '') for x in self._pos.get('UniqueID', [])]
)
Expand Down
14 changes: 8 additions & 6 deletions lib/matplotlib/backends/backend_pgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,12 +990,14 @@ def savefig(self, figure=None, **kwargs):
# luatex<0.85; they were renamed to \pagewidth and \pageheight
# on luatex>=0.85.
self._file.write(
br'\newpage'
br'\ifdefined\pdfpagewidth\pdfpagewidth'
br'\else\pagewidth\fi=%ain'
br'\ifdefined\pdfpageheight\pdfpageheight'
br'\else\pageheight\fi=%ain'
b'%%\n' % (width, height)
(
r'\newpage'
r'\ifdefined\pdfpagewidth\pdfpagewidth'
fr'\else\pagewidth\fi={width}in'
r'\ifdefined\pdfpageheight\pdfpageheight'
fr'\else\pageheight\fi={height}in'
'%%\n'
).encode("ascii")
)
figure.savefig(self._file, format="pgf", **kwargs)
self._n_figures += 1
Expand Down