1 # -*- coding: utf-8 -*-
4 # This file is part of LyX, the document processor.
5 # Licence details can be found in the file COPYING.
7 # \author Angus Leeming
10 # Full author contact details are available in file CREDITS
13 # This script converts an XFIG image to something that latex can process
14 # into high quality PostScript.
17 # python fig2pstex.py ${base}.fig ${base}.pstex
18 # This command generates
19 # ${base}.eps the converted eps file
20 # ${base}.pstex a tex file that can be included in your latex document
21 # using '\input{${output}}'.
24 # Do not use this command as
25 # python fig2pstex.py file.fig file.eps
26 # the real eps file will be overwritten by a tex file named file.eps.
29 from __future__ import print_function
32 # We expect two args, the names of the input and output files.
33 if len(sys.argv) != 3:
36 input, output = sys.argv[1:]
38 # Fail silently if the file doesn't exist
39 if not os.path.isfile(input):
42 # Strip the extension from ${output}
43 outbase = os.path.splitext(output)[0]
45 # Generate the EPS file
46 # Generate the PSTEX_T file
47 if os.system('fig2dev -Lpstex %s %s.eps' % (input, outbase)) != 0 or \
48 os.system('fig2dev -Lpstex_t -p%s %s %s' % (outbase, input, output)) != 0:
49 print ('fig2dev fails')