30
30
###############################################################################
31
31
32
32
33
- _luatex_version_re = re .compile (
34
- r'This is LuaTeX, Version (?:beta-)?([0-9]+)\.([0-9]+)\.([0-9]+)'
35
- )
36
-
37
-
38
33
@cbook .deprecated ("3.0" )
39
34
def get_texcommand ():
40
35
"""Get chosen TeX system from rc."""
@@ -43,18 +38,6 @@ def get_texcommand():
43
38
return texsystem if texsystem in texsystem_options else "xelatex"
44
39
45
40
46
- def _get_lualatex_version ():
47
- """Get version of luatex"""
48
- output = subprocess .check_output (['lualatex' , '--version' ])
49
- return _parse_lualatex_version (output .decode ())
50
-
51
-
52
- def _parse_lualatex_version (output ):
53
- '''parse the lualatex version from the output of `lualatex --version`'''
54
- match = _luatex_version_re .match (output )
55
- return tuple (map (int , match .groups ()))
56
-
57
-
58
41
def get_fontspec ():
59
42
"""Build fontspec preamble from rc."""
60
43
latex_fontspec = []
@@ -1171,26 +1154,23 @@ def savefig(self, figure=None, **kwargs):
1171
1154
if self ._n_figures == 0 :
1172
1155
self ._write_header (width , height )
1173
1156
else :
1174
- self ._file .write (self ._build_newpage_command (width , height ))
1157
+ # \pdfpagewidth and \pdfpageheight exist on pdftex, xetex, and
1158
+ # luatex<0.85; they were renamed to \pagewidth and \pageheight
1159
+ # on luatex>=0.85.
1160
+ self ._file .write (
1161
+ br'\newpage'
1162
+ br'\ifdefined\pdfpagewidth\pdfpagewidth'
1163
+ br'\else\pagewidth\fi=%ain'
1164
+ br'\ifdefined\pdfpageheight\pdfpageheight'
1165
+ br'\else\pageheight\fi=%ain'
1166
+ b'%%\n ' % (width , height )
1167
+ )
1175
1168
1176
1169
figure .savefig (self ._file , format = "pgf" , ** kwargs )
1177
1170
self ._n_figures += 1
1178
1171
finally :
1179
1172
figure .canvas = orig_canvas
1180
1173
1181
- def _build_newpage_command (self , width , height ):
1182
- r'''LuaLaTeX from version 0.85 removed the `\pdf*` primitives,
1183
- so we need to check the lualatex version and use `\pagewidth` if
1184
- the version is 0.85 or newer
1185
- '''
1186
- texcommand = rcParams ["pgf.texsystem" ]
1187
- if texcommand == 'lualatex' and _get_lualatex_version () >= (0 , 85 , 0 ):
1188
- cmd = r'\page'
1189
- else :
1190
- cmd = r'\pdfpage'
1191
- newpage = r'\newpage{cmd}width={w}in,{cmd}height={h}in%' + '\n '
1192
- return newpage .format (cmd = cmd , w = width , h = height ).encode ('utf-8' )
1193
-
1194
1174
def get_pagecount (self ):
1195
1175
"""
1196
1176
Returns the current number of pages in the multipage pdf file.
0 commit comments