2 # This file is part of LyX, the document processor.
3 # Licence details can be found in the file COPYING.
5 # \author Angus Leeming
8 # Full author contact details are available in file CREDITS
11 # This script converts an XFIG image to something that latex can process
12 # into high quality PostScript.
15 # python fig2pstex.py ${base}.fig ${base}.pstex
16 # This command generates
17 # ${base}.eps the converted eps file
18 # ${base}.pstex a tex file that can be included in your latex document
19 # using '\input{${output}}'.
22 # Do not use this command as
23 # python fig2pstex.py file.fig file.eps
24 # the real eps file will be overwritten by a tex file named file.eps.
29 # We expect two args, the names of the input and output files.
30 if len(sys.argv) != 3:
33 input, output = sys.argv[1:]
35 # Fail silently if the file doesn't exist
36 if not os.path.isfile(input):
39 # Strip the extension from ${output}
40 outbase = os.path.splitext(output)[0]
42 # Generate the EPS file
43 # Generate the PSTEX_T file
44 if os.system(f'fig2dev -Lpstex {input} {outbase}.eps') != 0 or \
45 os.system(f'fig2dev -Lpstex_t -p{outbase} {input} {output}') != 0:
46 print ('fig2dev fails')