mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Add support for inkscape 1.0
Command line syntax has changed. We now check for the version and use the appropriate cl options. Fixes #11742
This commit is contained in:
parent
125f5d5d20
commit
74f831e06d
108
lib/configure.py
108
lib/configure.py
@ -539,6 +539,15 @@ def checkInkscape():
|
|||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
return 'inkscape'
|
return 'inkscape'
|
||||||
|
|
||||||
|
def checkInkscapeStable():
|
||||||
|
''' Check whether we use Inkscape >= 1.0 '''
|
||||||
|
version_string = cmdOutput("inkscape --version")
|
||||||
|
if version_string.find('0.9') > 0:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def checkLatex(dtl_tools):
|
def checkLatex(dtl_tools):
|
||||||
''' Check latex, return lyx_check_config '''
|
''' Check latex, return lyx_check_config '''
|
||||||
path, LATEX = checkProg('a Latex2e program', ['latex $$i', 'latex2e $$i'])
|
path, LATEX = checkProg('a Latex2e program', ['latex $$i', 'latex2e $$i'])
|
||||||
@ -1006,13 +1015,22 @@ def checkConverterEntries():
|
|||||||
\converter fig pdftex "python -tt $$s/scripts/fig2pdftex.py $$i $$o" ""
|
\converter fig pdftex "python -tt $$s/scripts/fig2pdftex.py $$i $$o" ""
|
||||||
\converter fig pstex "python -tt $$s/scripts/fig2pstex.py $$i $$o" ""''')
|
\converter fig pstex "python -tt $$s/scripts/fig2pstex.py $$i $$o" ""''')
|
||||||
#
|
#
|
||||||
checkProg('a SVG -> PDFTeX converter', [inkscape_cl],
|
if inkscape_stable:
|
||||||
rc_entry = [ r'\converter svg pdftex "python -tt $$s/scripts/svg2pdftex.py %% $$p$$i $$p$$o" ""'],
|
checkProg('a SVG -> PDFTeX converter', [inkscape_cl],
|
||||||
path = [inkscape_path])
|
rc_entry = [ r'\converter svg pdftex "python -tt $$s/scripts/svg2pdftex.py %% $$p$$i $$p$$o" ""'],
|
||||||
#
|
path = [inkscape_path])
|
||||||
checkProg('a SVG -> PSTeX converter', [inkscape_cl],
|
#
|
||||||
rc_entry = [ r'\converter svg pstex "python -tt $$s/scripts/svg2pstex.py %% $$p$$i $$p$$o" ""'],
|
checkProg('a SVG -> PSTeX converter', [inkscape_cl],
|
||||||
path = [inkscape_path])
|
rc_entry = [ r'\converter svg pstex "python -tt $$s/scripts/svg2pstex.py %% $$p$$i $$p$$o" ""'],
|
||||||
|
path = [inkscape_path])
|
||||||
|
else:
|
||||||
|
checkProg('a SVG -> PDFTeX converter', [inkscape_cl],
|
||||||
|
rc_entry = [ r'\converter svg pdftex "python -tt $$s/scripts/svg2pdftex.py --unstable %% $$p$$i $$p$$o" ""'],
|
||||||
|
path = [inkscape_path])
|
||||||
|
#
|
||||||
|
checkProg('a SVG -> PSTeX converter', [inkscape_cl],
|
||||||
|
rc_entry = [ r'\converter svg pstex "python -tt $$s/scripts/svg2pstex.py --unstable %% $$p$$i $$p$$o" ""'],
|
||||||
|
path = [inkscape_path])
|
||||||
#
|
#
|
||||||
checkProg('a TIFF -> PS converter', ['tiff2ps $$i > $$o'],
|
checkProg('a TIFF -> PS converter', ['tiff2ps $$i > $$o'],
|
||||||
rc_entry = [ r'\converter tiff eps "%%" ""'])
|
rc_entry = [ r'\converter tiff eps "%%" ""'])
|
||||||
@ -1023,17 +1041,31 @@ def checkConverterEntries():
|
|||||||
\converter tgif png "tgif -print -color -png -o $$d $$i" ""
|
\converter tgif png "tgif -print -color -png -o $$d $$i" ""
|
||||||
\converter tgif pdf6 "tgif -print -color -pdf -stdout $$i > $$o" ""'''])
|
\converter tgif pdf6 "tgif -print -color -pdf -stdout $$i > $$o" ""'''])
|
||||||
#
|
#
|
||||||
checkProg('a WMF -> EPS converter', ['metafile2eps $$i $$o', 'wmf2eps -o $$o $$i', inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-eps=$$o'],
|
# inkscape 1.0 has changed cl options
|
||||||
rc_entry = [ r'\converter wmf eps "%%" ""'])
|
if inkscape_stable:
|
||||||
#
|
checkProg('a WMF -> EPS converter', ['metafile2eps $$i $$o', 'wmf2eps -o $$o $$i', inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
|
||||||
checkProg('an EMF -> EPS converter', ['metafile2eps $$i $$o', inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-eps=$$o'],
|
rc_entry = [ r'\converter wmf eps "%%" ""'])
|
||||||
rc_entry = [ r'\converter emf eps "%%" ""'])
|
#
|
||||||
#
|
checkProg('an EMF -> EPS converter', ['metafile2eps $$i $$o', inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
|
||||||
checkProg('a WMF -> PDF converter', [inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-pdf=$$o'],
|
rc_entry = [ r'\converter emf eps "%%" ""'])
|
||||||
rc_entry = [ r'\converter wmf pdf6 "%%" ""'])
|
#
|
||||||
#
|
checkProg('a WMF -> PDF converter', [inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
|
||||||
checkProg('an EMF -> PDF converter', [inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-pdf=$$o'],
|
rc_entry = [ r'\converter wmf pdf6 "%%" ""'])
|
||||||
rc_entry = [ r'\converter emf pdf6 "%%" ""'])
|
#
|
||||||
|
checkProg('an EMF -> PDF converter', [inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
|
||||||
|
rc_entry = [ r'\converter emf pdf6 "%%" ""'])
|
||||||
|
else:
|
||||||
|
checkProg('a WMF -> EPS converter', ['metafile2eps $$i $$o', 'wmf2eps -o $$o $$i', inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-eps=$$o'],
|
||||||
|
rc_entry = [ r'\converter wmf eps "%%" ""'])
|
||||||
|
#
|
||||||
|
checkProg('an EMF -> EPS converter', ['metafile2eps $$i $$o', inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-eps=$$o'],
|
||||||
|
rc_entry = [ r'\converter emf eps "%%" ""'])
|
||||||
|
#
|
||||||
|
checkProg('a WMF -> PDF converter', [inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-pdf=$$o'],
|
||||||
|
rc_entry = [ r'\converter wmf pdf6 "%%" ""'])
|
||||||
|
#
|
||||||
|
checkProg('an EMF -> PDF converter', [inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-pdf=$$o'],
|
||||||
|
rc_entry = [ r'\converter emf pdf6 "%%" ""'])
|
||||||
# Only define a converter to pdf6 for graphics
|
# Only define a converter to pdf6 for graphics
|
||||||
checkProg('an EPS -> PDF converter', ['epstopdf'],
|
checkProg('an EPS -> PDF converter', ['epstopdf'],
|
||||||
rc_entry = [ r'\converter eps pdf6 "epstopdf --outfile=$$o $$i" ""'])
|
rc_entry = [ r'\converter eps pdf6 "epstopdf --outfile=$$o $$i" ""'])
|
||||||
@ -1078,20 +1110,37 @@ def checkConverterEntries():
|
|||||||
rc_entry = [ r'\converter svg svgz "%%" ""'])
|
rc_entry = [ r'\converter svg svgz "%%" ""'])
|
||||||
# Only define a converter to pdf6 for graphics
|
# Only define a converter to pdf6 for graphics
|
||||||
# Prefer rsvg-convert over inkscape since it is faster (see http://www.lyx.org/trac/ticket/9891)
|
# Prefer rsvg-convert over inkscape since it is faster (see http://www.lyx.org/trac/ticket/9891)
|
||||||
checkProg('a SVG -> PDF converter', ['rsvg-convert -f pdf -o $$o $$i', inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-pdf=$$o'],
|
# inkscape 1.0 has changed cl options
|
||||||
rc_entry = [ r'''\converter svg pdf6 "%%" ""
|
if inkscape_stable:
|
||||||
|
checkProg('a SVG -> PDF converter', ['rsvg-convert -f pdf -o $$o $$i', inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
|
||||||
|
rc_entry = [ r'''\converter svg pdf6 "%%" ""
|
||||||
\converter svgz pdf6 "%%" ""'''],
|
\converter svgz pdf6 "%%" ""'''],
|
||||||
path = ['', inkscape_path])
|
path = ['', inkscape_path])
|
||||||
#
|
#
|
||||||
checkProg('a SVG -> EPS converter', ['rsvg-convert -f ps -o $$o $$i', inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-eps=$$o'],
|
checkProg('a SVG -> EPS converter', ['rsvg-convert -f ps -o $$o $$i', inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
|
||||||
rc_entry = [ r'''\converter svg eps "%%" ""
|
rc_entry = [ r'''\converter svg eps "%%" ""
|
||||||
\converter svgz eps "%%" ""'''],
|
\converter svgz eps "%%" ""'''],
|
||||||
path = ['', inkscape_path])
|
path = ['', inkscape_path])
|
||||||
#
|
#
|
||||||
checkProg('a SVG -> PNG converter', ['rsvg-convert -f png -o $$o $$i', inkscape_cl + ' --without-gui --file=$$i --export-png=$$o'],
|
checkProg('a SVG -> PNG converter', ['rsvg-convert -f png -o $$o $$i', inkscape_cl + ' $$i --export-filename=$$o'],
|
||||||
rc_entry = [ r'''\converter svg png "%%" "",
|
rc_entry = [ r'''\converter svg png "%%" "",
|
||||||
\converter svgz png "%%" ""'''],
|
\converter svgz png "%%" ""'''],
|
||||||
path = ['', inkscape_path])
|
path = ['', inkscape_path])
|
||||||
|
else:
|
||||||
|
checkProg('a SVG -> PDF converter', ['rsvg-convert -f pdf -o $$o $$i', inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-pdf=$$o'],
|
||||||
|
rc_entry = [ r'''\converter svg pdf6 "%%" ""
|
||||||
|
\converter svgz pdf6 "%%" ""'''],
|
||||||
|
path = ['', inkscape_path])
|
||||||
|
#
|
||||||
|
checkProg('a SVG -> EPS converter', ['rsvg-convert -f ps -o $$o $$i', inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-eps=$$o'],
|
||||||
|
rc_entry = [ r'''\converter svg eps "%%" ""
|
||||||
|
\converter svgz eps "%%" ""'''],
|
||||||
|
path = ['', inkscape_path])
|
||||||
|
#
|
||||||
|
checkProg('a SVG -> PNG converter', ['rsvg-convert -f png -o $$o $$i', inkscape_cl + ' --without-gui --file=$$i --export-png=$$o'],
|
||||||
|
rc_entry = [ r'''\converter svg png "%%" "",
|
||||||
|
\converter svgz png "%%" ""'''],
|
||||||
|
path = ['', inkscape_path])
|
||||||
#
|
#
|
||||||
checkProg('Gnuplot', ['gnuplot'],
|
checkProg('Gnuplot', ['gnuplot'],
|
||||||
rc_entry = [ r'''\Format gnuplot "gp, gnuplot" "Gnuplot" "" "" "" "vector" "text/plain"
|
rc_entry = [ r'''\Format gnuplot "gp, gnuplot" "Gnuplot" "" "" "" "vector" "text/plain"
|
||||||
@ -1869,6 +1918,7 @@ Format %i
|
|||||||
# On Windows, we need to call the "inkscape.com" wrapper
|
# On Windows, we need to call the "inkscape.com" wrapper
|
||||||
# for command line purposes. Other OSes do not differentiate.
|
# for command line purposes. Other OSes do not differentiate.
|
||||||
inkscape_cl = inkscape_gui
|
inkscape_cl = inkscape_gui
|
||||||
|
inkscape_stable = checkInkscapeStable()
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
inkscape_cl = inkscape_gui.replace('.exe', '.com')
|
inkscape_cl = inkscape_gui.replace('.exe', '.com')
|
||||||
checkFormatEntries(dtl_tools)
|
checkFormatEntries(dtl_tools)
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
# with pdflatex into high quality PDF. It requires Inkscape.
|
# with pdflatex into high quality PDF. It requires Inkscape.
|
||||||
|
|
||||||
# Usage:
|
# Usage:
|
||||||
# python svg2pdftex.py [inkscape_command] inputfile.svg outputfile.pdf_tex
|
# python svg2pdftex.py [--unstable] [inkscape_command] inputfile.svg outputfile.pdf_tex
|
||||||
# This command generates
|
# This command generates
|
||||||
# 1. outputfile.pdf -- the converted PDF file (text from SVG stripped)
|
# 1. outputfile.pdf -- the converted PDF file (text from SVG stripped)
|
||||||
# 2. outputfile.pdf_tex -- a TeX file that can be included in your
|
# 2. outputfile.pdf_tex -- a TeX file that can be included in your
|
||||||
# LaTeX document using '\input{outputfile.pdf_text}'
|
# LaTeX document using '\input{outputfile.pdf_text}'
|
||||||
|
# use --unstable for inkscape < 1.0
|
||||||
#
|
#
|
||||||
# Note:
|
# Note:
|
||||||
# Do not use this command as
|
# Do not use this command as
|
||||||
@ -43,16 +44,29 @@ def runCommand(cmd):
|
|||||||
InkscapeCmd = "inkscape"
|
InkscapeCmd = "inkscape"
|
||||||
InputFile = ""
|
InputFile = ""
|
||||||
OutputFile = ""
|
OutputFile = ""
|
||||||
|
unstable = False
|
||||||
|
|
||||||
# We expect two or three args: the names of the input and output files
|
# We expect two to four args: the names of the input and output files
|
||||||
# and optionally the inkscape command (with path if needed).
|
# and optionally the inkscape command (with path if needed) and --unstable.
|
||||||
args = len(sys.argv)
|
args = len(sys.argv)
|
||||||
if args == 3:
|
if args == 3:
|
||||||
# Two args: input and output file only
|
# Two args: input and output file only
|
||||||
InputFile, OutputFile = sys.argv[1:]
|
InputFile, OutputFile = sys.argv[1:]
|
||||||
elif args == 4:
|
elif args == 4:
|
||||||
# Three args: first arg is inkscape command
|
# Three args: check whether we have --unstable as first arg
|
||||||
InkscapeCmd, InputFile, OutputFile = sys.argv[1:]
|
if sys.argv[1] == "--unstable":
|
||||||
|
unstable = True
|
||||||
|
InputFile, OutputFile = sys.argv[2:]
|
||||||
|
else:
|
||||||
|
InkscapeCmd, InputFile, OutputFile = sys.argv[1:]
|
||||||
|
elif args == 5:
|
||||||
|
# Four args: check whether we have --unstable as first arg
|
||||||
|
if sys.argv[1] != "--unstable":
|
||||||
|
# Invalid number of args. Exit with error.
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
unstable = True
|
||||||
|
InkscapeCmd, InputFile, OutputFile = sys.argv[2:]
|
||||||
else:
|
else:
|
||||||
# Invalid number of args. Exit with error.
|
# Invalid number of args. Exit with error.
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -68,7 +82,10 @@ OutBase = os.path.splitext(OutputFile)[0]
|
|||||||
# while outsourcing the text to a LaTeX file ${OutBase}.pdf_tex which includes and overlays
|
# while outsourcing the text to a LaTeX file ${OutBase}.pdf_tex which includes and overlays
|
||||||
# the PDF image and can be \input to LaTeX files. We rename the latter file to ${OutputFile}
|
# the PDF image and can be \input to LaTeX files. We rename the latter file to ${OutputFile}
|
||||||
# (although this is probably the name it already has).
|
# (although this is probably the name it already has).
|
||||||
runCommand([r'%s' % InkscapeCmd, '--file=%s' % InputFile, '--export-pdf=%s.pdf' % OutBase, '--export-latex'])
|
if unstable:
|
||||||
|
runCommand([r'%s' % InkscapeCmd, '--file=%s' % InputFile, '--export-pdf=%s.pdf' % OutBase, '--export-latex'])
|
||||||
|
else:
|
||||||
|
runCommand([r'%s' % InkscapeCmd, '%s' % InputFile, '--export-filename=%s.pdf' % OutBase, '--export-latex'])
|
||||||
|
|
||||||
os.rename('%s.pdf_tex' % OutBase, OutputFile)
|
os.rename('%s.pdf_tex' % OutBase, OutputFile)
|
||||||
|
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
# with latex into high quality DVI/PostScript. It requires Inkscape.
|
# with latex into high quality DVI/PostScript. It requires Inkscape.
|
||||||
|
|
||||||
# Usage:
|
# Usage:
|
||||||
# python svg2pstex.py [inkscape_command] inputfile.svg outputfile.eps_tex
|
# python svg2pstex.py [--unstable] [inkscape_command] inputfile.svg outputfile.eps_tex
|
||||||
# This command generates
|
# This command generates
|
||||||
# 1. outputfile.eps -- the converted EPS file (text from SVG stripped)
|
# 1. outputfile.eps -- the converted EPS file (text from SVG stripped)
|
||||||
# 2. outputfile.eps_tex -- a TeX file that can be included in your
|
# 2. outputfile.eps_tex -- a TeX file that can be included in your
|
||||||
# LaTeX document using '\input{outputfile.eps_text}'
|
# LaTeX document using '\input{outputfile.eps_text}'
|
||||||
|
# use --unstable for inkscape < 1.0
|
||||||
#
|
#
|
||||||
# Note:
|
# Note:
|
||||||
# Do not use this command as
|
# Do not use this command as
|
||||||
@ -46,16 +47,29 @@ def runCommand(cmd):
|
|||||||
InkscapeCmd = "inkscape"
|
InkscapeCmd = "inkscape"
|
||||||
InputFile = ""
|
InputFile = ""
|
||||||
OutputFile = ""
|
OutputFile = ""
|
||||||
|
unstable = False
|
||||||
|
|
||||||
# We expect two or three args: the names of the input and output files
|
# We expect two to four args: the names of the input and output files
|
||||||
# and optionally the inkscape command (with path if needed).
|
# and optionally the inkscape command (with path if needed) and --unstable.
|
||||||
args = len(sys.argv)
|
args = len(sys.argv)
|
||||||
if args == 3:
|
if args == 3:
|
||||||
# Two args: input and output file only
|
# Two args: input and output file only
|
||||||
InputFile, OutputFile = sys.argv[1:]
|
InputFile, OutputFile = sys.argv[1:]
|
||||||
elif args == 4:
|
elif args == 4:
|
||||||
# Three args: first arg is inkscape command
|
# Three args: check whether we have --unstable as first arg
|
||||||
InkscapeCmd, InputFile, OutputFile = sys.argv[1:]
|
if sys.argv[1] == "--unstable":
|
||||||
|
unstable = True
|
||||||
|
InputFile, OutputFile = sys.argv[2:]
|
||||||
|
else:
|
||||||
|
InkscapeCmd, InputFile, OutputFile = sys.argv[1:]
|
||||||
|
elif args == 5:
|
||||||
|
# Four args: check whether we have --unstable as first arg
|
||||||
|
if sys.argv[1] != "--unstable":
|
||||||
|
# Invalid number of args. Exit with error.
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
unstable = True
|
||||||
|
InkscapeCmd, InputFile, OutputFile = sys.argv[2:]
|
||||||
else:
|
else:
|
||||||
# Invalid number of args. Exit with error.
|
# Invalid number of args. Exit with error.
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user