From dd7ae7278998aa18a972e5f8a8d62406772437bd Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Sat, 31 May 2003 16:52:33 +0000 Subject: [PATCH] Prepare the way for a shiny new external inset. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7072 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 8 +++++ lib/configure.m4 | 60 ++++++++++++++++++++++-------------- lib/scripts/fig2pdftex.sh | 65 +++++++++++++++++++++++++++------------ lib/scripts/fig2pstex.sh | 41 ++++++++++++++++++++++++ 4 files changed, 131 insertions(+), 43 deletions(-) create mode 100644 lib/scripts/fig2pstex.sh diff --git a/lib/ChangeLog b/lib/ChangeLog index a5cb363706..2d4bb3ee92 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,11 @@ +2003-05-31 Angus Leeming + + * configure.m4 (latex_to_html_command): add a bunch of formats and + converters that are to be used by the external inset. + + * fig2pdftex.sh: make it work as a "converter". + * fig2pstex.sh: new file: a converter from xfig to pstex_t. + 2003-05-30 John Levon * ui/stdmenus.ui: Force Normal Space -> Inter-word Space diff --git a/lib/configure.m4 b/lib/configure.m4 index 6485b099bf..8c73c77db2 100644 --- a/lib/configure.m4 +++ b/lib/configure.m4 @@ -430,62 +430,75 @@ cat >$outfile < \$\$o" "" +\\converter docbook dvi "$docbook_to_dvi_command" "" +\\converter docbook html "$docbook_to_html_command" "" \\converter dvi pdf3 "$dvi_to_pdf_command" "" \\converter dvi ps "$dvi_to_ps_command" "" -\\converter ps pdf "$ps_to_pdf_command" "" -\\converter ps fax "$fax_command" "" -\\converter linuxdoc lyx "$linuxdoc_to_lyx_command" "" -\\converter linuxdoc latex "$linuxdoc_to_latex_command" "" +\\converter fen asciichess "python \$\$s/fen2ascii.py \$\$i \$\$o" "" +\\converter fig pdftex "sh \$\$s/fig2pdftex.sh \$\$i \$\$o" "" +\\converter fig pstex "sh \$\$s/fig2pstex.sh \$\$i \$\$o" "" +\\converter html latex "$html_to_latex_command" "" +\\converter latex html "$latex_to_html_command" "originaldir,needaux" +\\converter latex dvi "$latex_to_dvi" "latex" +\\converter latex lyx "$tex_to_lyx_command" "" +\\converter latex pdf2 "$latex_to_pdf" "latex" \\converter linuxdoc dvi "$linuxdoc_to_dvi_command" "" \\converter linuxdoc html "$linuxdoc_to_html_command" "" -\\converter docbook dvi "$docbook_to_dvi_command" "" -\\converter docbook html "$docbook_to_html_command" "" -\\converter lyxpreview ppm "$lyxpreview_to_bitmap_command" "" - -\\converter latex lyx "$tex_to_lyx_command" "" +\\converter linuxdoc latex "$linuxdoc_to_latex_command" "" +\\converter linuxdoc lyx "$linuxdoc_to_lyx_command" "" +\\converter literate latex "$literate_to_tex_command" "" \\converter literate lyx "$literate_to_lyx_command" "" -\\converter html latex "$html_to_latex_command" "" +\\converter lyxpreview ppm "$lyxpreview_to_bitmap_command" "" +\\converter ps fax "$fax_command" "" +\\converter ps pdf "$ps_to_pdf_command" "" \\converter word latex "$word_to_latex_command" "" \\viewer dvi "$DVI_VIEWER" \\viewer html "$HTML_VIEWER" \\viewer pdf "$PDF_VIEWER" +\\viewer pdf2 "$PDF_VIEWER" +\\viewer pdf3 "$PDF_VIEWER" \\viewer ps "$GHOSTVIEW -swap" \\viewer eps "$GHOSTVIEW" @@ -501,6 +514,7 @@ if test "$FIG2DEV" = "fig2dev"; then cat >>$outfile < /dev/null || exit 1 + + input=$1 + pdftex_t=$2 + pdftex=$3.pdf fig2dev -Lpdftex ${input} ${pdftex} - fig2dev -Lpdftex_t -p$1 ${input} ${pdftex_t} + fig2dev -Lpdftex_t -p${outbase} ${input} ${pdftex_t} exit 0; } @@ -35,13 +40,20 @@ modern_xfig() { # Older versions of xfig cannot do this, so we emulate the behaviour using # pstex and pstex_t output. legacy_xfig() { - input=$1.fig - pstex=$1.pstex - png=$1.png - pdftex_t=$1.pdftex_t + echo legacy_xfig + + # Can we find fig2dev, eps2eos or gs? + type fig2dev > /dev/null || exit 1 + type eps2eps > /dev/null || exit 1 + type gs > /dev/null || exit 1 + + input=$1 + pdftex_t=$2 + png=$3.png + pstex=$3.pstex fig2dev -Lpstex ${input} ${pstex} - fig2dev -Lpstex_t -p$1 ${input} ${pdftex_t} + fig2dev -Lpstex_t -p${outbase} ${input} ${pdftex_t} # Convert the ${pstex} EPS file (free of "special" text) to PDF format # using gs. @@ -73,29 +85,42 @@ legacy_xfig() { # The main logic of the script is below. # All it does is ascertain which of the two functions above to call. -# We expect a single arg, the name of the input file. -test $# -eq 1 || exit 1 +# We expect two args, the names of the input and output files. +test $# -eq 2 || exit 1 + +input=$1 +output=$2 -# Remove the .fig extension -input=`basename $1` -base=`echo ${input} | sed 's/\.fig$//'` +# Strip the extension from ${output} +outbase=`echo ${output} | sed 's/[.][^.]*$//'` # Ascertain whether fig2dev is "modern enough". # Here "modern" means "fig2dev Version 3.2 Patchlevel 4" version_info=`fig2dev -h | sed '/^fig2dev/! d'` # If no line begins "fig2dev" then default to legacy_xfig -test "x${version_info}" = "x" && legacy_xfig ${base} +test "x${version_info}" = "x" && { + legacy_xfig ${input} ${output} ${outbase} +} version=`echo ${version_info} | cut -d' ' -f3` patchlevel=`echo ${version_info} | cut -d' ' -f5` # If we cannot extract the version of patchlevel info # then default to legacy_xfig -test "x${version}" = "x" -o "x${patchlevel}" = "x" && legacy_xfig ${base} -echo ${version} ${patchlevel} | grep '[0-9]!' -o && legacy_xfig ${base} +test "x${version}" = "x" -o "x${patchlevel}" = "x" && { + legacy_xfig ${input} ${output} ${outbase} +} +echo ${version} ${patchlevel} | grep '[0-9]!' -o && { + legacy_xfig ${input} ${output} ${outbase} +} -# So, is it am old version? -test ${version} != "3.2" -o ${patchlevel} -lt 4 && legacy_xfig ${base} +# So, is it an old version? +test ${version} != "3.2" -o ${patchlevel} -lt 4 && { + legacy_xfig ${input} ${output} ${outbase} +} # I guess not ;-) -modern_xfig ${base} + +# Commented out for now to test legacy_xfig... +#modern_xfig ${input} ${output} ${outbase} +legacy_xfig ${input} ${output} ${outbase} # The end diff --git a/lib/scripts/fig2pstex.sh b/lib/scripts/fig2pstex.sh new file mode 100644 index 0000000000..db612748bf --- /dev/null +++ b/lib/scripts/fig2pstex.sh @@ -0,0 +1,41 @@ +#! /bin/sh + +# file fig2pstex.sh +# This file is part of LyX, the document processor. +# Licence details can be found in the file COPYING. +# +# author Angus Leeming +# +# Full author contact details are available in file CREDITS + + +# This script converts an XFIG image to something that latex can process +# into high quality PostScript. + +# Usage: sh fig2pstex.sh ${input} ${output} +# to generate the pstex_t file ${output}. +# In turn this file will \includegraphics{${output_base}}. +# The necessary ${output_base}.eps is also generated by this script. +# +# Thereafter, you need only '\input{${output}}' in your latex document. + +# We expect two args, the names of the input and output files. +test $# -eq 2 || exit 1 + +# Can we find fig2dev? +type fig2dev > /dev/null || exit 1 + +input=$1 +output=$2 + +# Strip the extension from ${output} +outbase=`echo ${output} | sed 's/[.][^.]*$//'` + +# Generate the EPS file +outeps=${outbase}.eps +fig2dev -Lpstex ${input} ${outeps} + +# Generate the PSTEX_T file +fig2dev -Lpstex_t -p${outbase} ${input} ${output} + +# The end -- 2.39.2