3030###############################################################################
3131
3232
33- _luatex_version_re = re .compile (
34- r'This is LuaTeX, Version (?:beta-)?([0-9]+)\.([0-9]+)\.([0-9]+)'
35- )
36-
37-
3833@cbook .deprecated ("3.0" )
3934def get_texcommand ():
4035 """Get chosen TeX system from rc."""
@@ -43,18 +38,6 @@ def get_texcommand():
4338 return texsystem if texsystem in texsystem_options else "xelatex"
4439
4540
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-
5841def get_fontspec ():
5942 """Build fontspec preamble from rc."""
6043 latex_fontspec = []
@@ -1171,26 +1154,23 @@ def savefig(self, figure=None, **kwargs):
11711154 if self ._n_figures == 0 :
11721155 self ._write_header (width , height )
11731156 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+ )
11751168
11761169 figure .savefig (self ._file , format = "pgf" , ** kwargs )
11771170 self ._n_figures += 1
11781171 finally :
11791172 figure .canvas = orig_canvas
11801173
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-
11941174 def get_pagecount (self ):
11951175 """
11961176 Returns the current number of pages in the multipage pdf file.
0 commit comments