lyxpreview2bitmap tweaks

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_3_X@6427 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2003-03-10 16:38:21 +00:00
parent 23e328ae3c
commit c797a17794
3 changed files with 36 additions and 16 deletions

View File

@ -1,3 +1,9 @@
2003-03-10 Angus Leeming <leeming@lyx.org>
* scripts/lyxpreview2bitmap.sh: use variables for the names of
'latex', 'dvips', 'gs' and 'pnmcrop' and move their definition to
the top of the script.
2003-03-10 Michael Schmitt <Michael.Schmitt@teststep.org> 2003-03-10 Michael Schmitt <Michael.Schmitt@teststep.org>
* configure.m4: fix the tgif converters * configure.m4: fix the tgif converters

View File

@ -51,6 +51,14 @@
# \converter lyxpreview ${FORMAT} "lyxpreview2bitmap.sh" "" # \converter lyxpreview ${FORMAT} "lyxpreview2bitmap.sh" ""
# where ${FORMAT} is either ppm or png. # where ${FORMAT} is either ppm or png.
# These four programs are used by the script.
# Adjust their names to suit your setup.
LATEX=latex
DVIPS=dvips
GS=gs
PNMCROP=pnmcrop
readonly LATEX DVIPS GS PNMCROP
# Three helper functions. # Three helper functions.
FIND_IT () FIND_IT ()
{ {
@ -65,7 +73,7 @@ FIND_IT ()
BAIL_OUT () BAIL_OUT ()
{ {
# Remove everything except the original .tex file. # Remove everything except the original .tex file.
FILES=`ls ${BASE}* | sed -e "/${BASE}.tex/d"` FILES=`ls ${BASE}* | sed -e "/${BASE}\.tex/d"`
rm -f ${FILES} texput.log rm -f ${FILES} texput.log
echo "Leaving ${BASE}.tex in ${DIR}" echo "Leaving ${BASE}.tex in ${DIR}"
exit 1 exit 1
@ -73,8 +81,10 @@ BAIL_OUT ()
REQUIRED_VERSION () REQUIRED_VERSION ()
{ {
test $# -eq 1 || exit 1
echo "We require preview.sty version 0.73 or newer. You're using" echo "We require preview.sty version 0.73 or newer. You're using"
grep 'Package: preview' ${LOGFILE} grep 'Package: preview' $1
} }
# Preliminary check. # Preliminary check.
@ -101,9 +111,9 @@ else
fi fi
# We use latex, dvips and gs, so check that they're all there. # We use latex, dvips and gs, so check that they're all there.
FIND_IT latex FIND_IT ${LATEX}
FIND_IT dvips FIND_IT ${DVIPS}
FIND_IT gs FIND_IT ${GS}
# Initialise some variables. # Initialise some variables.
TEXFILE=${BASE}.tex TEXFILE=${BASE}.tex
@ -111,12 +121,13 @@ LOGFILE=${BASE}.log
DVIFILE=${BASE}.dvi DVIFILE=${BASE}.dvi
PSFILE=${BASE}.ps PSFILE=${BASE}.ps
METRICSFILE=${BASE}.metrics METRICSFILE=${BASE}.metrics
readonly TEXFILE LOGFILE DVIFILE PSFILE METRICSFILE
# LaTeX -> DVI. # LaTeX -> DVI.
cd ${DIR} cd ${DIR}
latex ${TEXFILE} || ${LATEX} ${TEXFILE} ||
{ {
echo "Failed: latex ${TEXFILE}" echo "Failed: ${LATEX} ${TEXFILE}"
BAIL_OUT BAIL_OUT
} }
@ -127,7 +138,7 @@ latex ${TEXFILE} ||
grep -E 'Preview: [ST]' ${LOGFILE} > ${METRICSFILE} || grep -E 'Preview: [ST]' ${LOGFILE} > ${METRICSFILE} ||
{ {
echo "Failed: grep -E 'Preview: [ST]' ${LOGFILE}" echo "Failed: grep -E 'Preview: [ST]' ${LOGFILE}"
REQUIRED_VERSION REQUIRED_VERSION ${LOGFILE}
BAIL_OUT BAIL_OUT
} }
@ -138,7 +149,7 @@ grep -E 'Preview: [ST]' ${LOGFILE} > ${METRICSFILE} ||
LINE=`grep 'Preview: Fontsize' ${LOGFILE}` || LINE=`grep 'Preview: Fontsize' ${LOGFILE}` ||
{ {
echo "Failed: grep 'Preview: Fontsize' ${LOGFILE}" echo "Failed: grep 'Preview: Fontsize' ${LOGFILE}"
REQUIRED_VERSION REQUIRED_VERSION ${LOGFILE}
BAIL_OUT BAIL_OUT
} }
# The sed script strips out everything that won't form a decimal number # The sed script strips out everything that won't form a decimal number
@ -166,9 +177,9 @@ RESOLUTION=`echo "scale=2; \
| bc` | bc`
# DVI -> PostScript # DVI -> PostScript
dvips -o ${PSFILE} ${DVIFILE} || ${DVIPS} -o ${PSFILE} ${DVIFILE} ||
{ {
echo "Failed: dvips -o ${PSFILE} ${DVIFILE}" echo "Failed: ${DVIPS} -o ${PSFILE} ${DVIFILE}"
BAIL_OUT BAIL_OUT
} }
@ -185,12 +196,12 @@ if [ ${INT_RESOLUTION} -gt 150 ]; then
ALPHA=2 ALPHA=2
fi fi
gs -q -dNOPAUSE -dBATCH -dSAFER \ ${GS} -q -dNOPAUSE -dBATCH -dSAFER \
-sDEVICE=${GSDEVICE} -sOutputFile=${BASE}%d.${GSSUFFIX} \ -sDEVICE=${GSDEVICE} -sOutputFile=${BASE}%d.${GSSUFFIX} \
-dGraphicsAlphaBit=${ALPHA} -dTextAlphaBits=${ALPHA} \ -dGraphicsAlphaBit=${ALPHA} -dTextAlphaBits=${ALPHA} \
-r${RESOLUTION} ${PSFILE} || -r${RESOLUTION} ${PSFILE} ||
{ {
echo "Failed: gs ${PSFILE}" echo "Failed: ${GS} ${PSFILE}"
BAIL_OUT BAIL_OUT
} }
@ -203,7 +214,7 @@ rm -f ${FILES} texput.log
# The bitmap files can have large amounts of whitespace to the left and # The bitmap files can have large amounts of whitespace to the left and
# right. This can be cropped if so desired. # right. This can be cropped if so desired.
CROP=1 CROP=1
type pnmcrop > /dev/null || CROP=0 type ${PNMCROP} > /dev/null || CROP=0
# There's no point cropping the image if using PNG images. If you want to # There's no point cropping the image if using PNG images. If you want to
# crop, use PPM. # crop, use PPM.
@ -211,8 +222,8 @@ type pnmcrop > /dev/null || CROP=0
if [ ${CROP} -eq 1 -a "${GSDEVICE}" = "pnmraw" ]; then if [ ${CROP} -eq 1 -a "${GSDEVICE}" = "pnmraw" ]; then
for FILE in ${BASE}*.${GSSUFFIX} for FILE in ${BASE}*.${GSSUFFIX}
do do
if pnmcrop -left ${FILE} 2> /dev/null |\ if ${PNMCROP} -left ${FILE} 2> /dev/null |\
pnmcrop -right 2> /dev/null > ${BASE}.tmp; then ${PNMCROP} -right 2> /dev/null > ${BASE}.tmp; then
mv ${BASE}.tmp ${FILE} mv ${BASE}.tmp ${FILE}
else else
rm -f ${BASE}.tmp rm -f ${BASE}.tmp

View File

@ -138,6 +138,9 @@ What's new
- fix problem in generation of the reLyX and noweb2lyx scripts - fix problem in generation of the reLyX and noweb2lyx scripts
- the names of the programs used by the lyxpreview2bitmap.sh can now
be more easily customized
- add a few autoconf-related files that were missing from the - add a few autoconf-related files that were missing from the
distribution distribution