]> git.lyx.org Git - lyx.git/commitdiff
Some Tender Loving Care for fig2pdftex.
authorAngus Leeming <leeming@lyx.org>
Thu, 12 Jun 2003 14:08:24 +0000 (14:08 +0000)
committerAngus Leeming <leeming@lyx.org>
Thu, 12 Jun 2003 14:08:24 +0000 (14:08 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7163 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ChangeLog
lib/configure.m4
lib/scripts/fig2pdftex.sh

index 1e56d08515816b39bb666ea86608f8f9adf6f00c..fa2ff045002dd0f291b069d98d74b86c78ab840a 100644 (file)
@@ -1,3 +1,10 @@
+2003-06-12  Angus Leeming  <leeming@lyx.org>
+
+       * scripts/fig2pdftex.sh (legacy_xfig): Use epstopdf, as suggested by
+       Martin Vermeer.
+
+       * configure.m4: add $$s/ to the lyxpreview2bitmap.sh path.
+
 2003-06-11  John Levon  <levon@movementarian.org>
 
        * ui/stdtoolbars.ui: move flags to ...
index 292fc269937bf39f371705ff19f6ba53aa6201a7..244ac42471f1e5a9d5c931a7f42704f953e13e47 100644 (file)
@@ -268,7 +268,7 @@ SEARCH_PROG([for a DVI to PDF converter],dvi_to_pdf_command,dvipdfm)
 test $dvi_to_pdf_command = "dvipdfm" && dvi_to_pdf_command="dvipdfm \$\$i"
 
 # We have a script to convert previewlyx to ppm
-lyxpreview_to_bitmap_command="lyxpreview2bitmap.sh"
+lyxpreview_to_bitmap_command='$$s/lyxpreview2bitmap.sh'
 
 # Search a *roff program (used to translate tables in ASCII export)
 LYXRC_PROG([for a *roff formatter], \ascii_roff_command, dnl
index c6bebf2affd8acd2a9f7fe846dfc698b4ba89ff9..8a9e43b753de31345f39ec503eac447bb65cab49 100644 (file)
 # to generate ${base}.pdftex_t
 # Thereafter, you need only '\input{${base}.pdftex_t}' in your latex document.
 
+# These are the external programs we use
+FIG2DEV=fig2dev
+# If using "legacy_xfig" only
+EPSTOPDF=epstopdf
+
+find_exe() {
+    test $# -eq 1 || exit 1
+
+    type $1 > /dev/null || {
+       echo "Unable to find \"$1\". Please install."
+       exit 1
+    }
+}
+
 # modern_xfig() and legacy_xfig() are the functions that do all the work.
 
 # Modern versions of xfig can output the image without "special" text as
 # a PDF file ${base}.pdf and place the text in a LaTeX file
 # ${base}.pdftex_t for typesetting by pdflatex itself.
 modern_xfig() {
-    echo modern_xfig
-
     # Can we find fig2dev?
-    type fig2dev > /dev/null || exit 1
+    find_exe ${FIG2DEV}
 
     input=$1
     pdftex_t=$2
     pdftex=$3.pdf
 
-    fig2dev -Lpdftex ${input} ${pdftex}
-    fig2dev -Lpdftex_t -p${outbase} ${input} ${pdftex_t}
+    ${FIG2DEV} -Lpdftex -p1 ${input} ${pdftex}
+    ${FIG2DEV} -Lpdftex_t -p${outbase} ${input} ${pdftex_t}
 
     exit 0;
 }
@@ -40,45 +52,23 @@ modern_xfig() {
 # Older versions of xfig cannot do this, so we emulate the behaviour using
 # pstex and pstex_t output.
 legacy_xfig() {
-    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
+    # Can we find fig2dev and epstopdf?
+    find_exe ${FIG2DEV}
+    find_exe ${EPSTOPDF}
 
     input=$1
     pdftex_t=$2
-    png=$3.png
+    pdf=$3.pdf
     pstex=$3.pstex
 
-    fig2dev -Lpstex ${input} ${pstex}
-    fig2dev -Lpstex_t -p${outbase} ${input} ${pdftex_t}
+    ${FIG2DEV} -Lpstex ${input} ${pstex}
+    ${FIG2DEV} -Lpstex_t -p${outbase} ${input} ${pdftex_t}
 
     # Convert the ${pstex} EPS file (free of "special" text) to PDF format
-    # using gs.
-
-    # gs is extremely fussy about the EPS files it converts, so ensure it is
-    # "clean" first.
-    clean=${pstex}.$$
-    eps2eps ${pstex} ${clean}
+    # using epstopdf.
+    ${EPSTOPDF} --outfile=${pdf} ${pstex}
     rm -f ${pstex}
 
-    # Extract the width and height of the image using gs' bbox device.
-    # Ie, take output that includes line "%%BoundingBox: 0 0 <width> <height>"
-    # and rewrite it as "-g<width>x<height>"
-    geometry=`gs -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox ${clean} 2>&1 | \
-       sed '/^%%BoundingBox/! d' | cut -d' ' -f4,5 | \
-       sed 's/^\([0-9]\{1,\}\) \([0-9]\{1,\}\)$/-g\1x\2/'`
-
-    # Generate a PNG file using the -g option to ensure the size is the same
-    # as the original.
-    # If we're using a version of gs that does not have a bbox device, then
-    # ${geometry} = "", so there are no unwanted side effects.
-    gs -q -dSAFER -dBATCH -dNOPAUSE ${geometry} -sDEVICE=png16m \
-       -sOutputFile=${png} ${clean}
-    rm -f ${clean}
-
     exit 0;
 }
 
@@ -95,32 +85,11 @@ output=$2
 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 ${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 ${input} ${output} ${outbase}
-}
-echo ${version} ${patchlevel} | grep '[0-9]!' -o && {
-    legacy_xfig ${input} ${output} ${outbase}
-}
-
-# So, is it an old version?
-test ${version} != "3.2" -o ${patchlevel} -lt 4 && {
-    legacy_xfig ${input} ${output} ${outbase}
-}
-# I guess not ;-)
+# If it is, then the help info will mention "pdftex_t" as one of the
+# available outputs.
+FUNCTION=modern_xfig
+${FIG2DEV} -h | grep 'pdftex_t' > /dev/null || FUNCTION=legacy_xfig
 
-# Commented out for now to test legacy_xfig...
-#modern_xfig ${input} ${output} ${outbase}
-legacy_xfig ${input} ${output} ${outbase}
+${FUNCTION} ${input} ${output} ${outbase}
 
 # The end