]> git.lyx.org Git - features.git/commitdiff
Augment the preliminary blurb, as suggested by Andr�.
authorAngus Leeming <leeming@lyx.org>
Thu, 5 Sep 2002 11:45:44 +0000 (11:45 +0000)
committerAngus Leeming <leeming@lyx.org>
Thu, 5 Sep 2002 11:45:44 +0000 (11:45 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5207 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ChangeLog
lib/scripts/lyxpreview2bitmap.sh

index acd3fef58719152df6ed0aaff66dd63af62d2c59..1e0c1fb3a0b08827a8d40dcdcb77414ebfbd609c 100644 (file)
@@ -1,3 +1,8 @@
+2002-09-05  Angus Leeming  <leeming@lyx.org>
+
+       * scripts/lyxpreview2bitmap.sh: augment the preliminary blurb, as
+       suggested by André.
+
 2002-09-04  Angus Leeming  <leeming@lyx.org>
 
        * scripts/lyxpreview2bitmap.sh: rename lyxpreview2ppm.sh as this.
index 4012f73d0ed5b54f715c7e285391cf0320d04b4b..408d5bb4cbe9faff049ad4b10e7474cb65c0c453 100644 (file)
@@ -1,33 +1,55 @@
 #! /bin/sh
 
-# \file tex2preview.sh
-# Copyright 2002 the LyX Team
+# file lyxpreview2bitmap.sh
 # Read the file COPYING
-# \author Angus Leeming, leeming@lyx.org
+#
+# author Angus Leeming
 # with much advice from David Kastrup, david.kastrup@t-online.de.
+#
+# Full author contact details are available in file CREDITS
 
 # This script takes a LaTeX file and generates bitmap image files,
 # one per page.
 
 # The idea is to use it with preview.sty from the preview-latex project
-# (http://preview-latex.sourceforge.net/) to create small bitmap previews of
-# things like math equations.
+# (http://preview-latex.sourceforge.net/) to create small bitmap
+# previews of things like math equations.
 
-# preview.sty can be obtained from CTAN/macros/latex/contrib/supported/preview.
+# preview.sty can be obtained from
+# CTAN/macros/latex/contrib/supported/preview.
 
 # This script takes three arguments:
 # TEXFILE:       the name of the .tex file to be converted.
 # SCALEFACTOR:   a scale factor, used to ascertain the resolution of the
 #                generated image which is then passed to gs.
-# OUTPUTFORMAT:  the format of the output bitmap image files. Two formats
-#                are recognised: PPM and PNG
+# OUTPUTFORMAT:  the format of the output bitmap image files.
+#                Two formats are recognised: "ppm" and "png".
 
 # If successful, this script will leave in dir ${DIR}:
-# ${BASE}\([0-9]*\).ppm/png:  a (possibly large) number of image files.
-# ${BASE}.metrics:            a file containing info needed by LyX to
-#                             position the images correctly on the screen.
+# a (possibly large) number of image files with names like
+#         ${BASE}\([0-9]*\).${SUFFIX} where SUFFIX is ppm or png.
+# a file containing info needed by LyX to position the images correctly
+# on the screen.
+#         ${BASE}.metrics
 # All other files ${BASE}* will be deleted.
 
+# A quick note on the choice of OUTPUTFORMAT:
+
+# In general files in PPM format are 10-100 times larger than the
+# equivalent files in PNG format. Larger files results in longer
+# reading and writing times as well as greater disk usage.
+
+# However, whilst the Qt image loader can load files in PNG format
+# without difficulty, the xforms image loader cannot. They must first
+# be converted to a loadable format (eg PPM!). Thus, previews will take
+# longer to appear if the xforms loader is used to load snippets in
+# PNG format.
+
+# You can always experiment by adding a line to your
+# ${LYXUSERDIR}/preferences file
+#        \converter lyxpreview ${FORMAT} "lyxpreview2bitmap.sh" ""
+# where ${FORMAT} is either ppm or png.
+
 # Three helper functions.
 FIND_IT () {
        which ${EXECUTABLE} > /dev/null
@@ -92,8 +114,10 @@ if [ $? -ne 0 ]; then
        BAIL_OUT
 fi
 
-# Parse ${LOGFILE} to obtain bounding box info to output to ${METRICSFILE}.
-# This extracts lines starting "Preview: Tightpage" and "Preview: Snippet".
+# Parse ${LOGFILE} to obtain bounding box info to output to
+# ${METRICSFILE}.
+# This extracts lines starting "Preview: Tightpage" and
+# "Preview: Snippet".
 grep -E 'Preview: [ST]' ${LOGFILE} > ${METRICSFILE}
 if [ $? -ne 0 ]; then
        echo "Failed: grep -E 'Preview: [ST]' ${LOGFILE}"
@@ -103,34 +127,37 @@ fi
 
 # Parse ${LOGFILE} to obtain ${RESOLUTION} for the gs process to follow.
 # 1. Extract font size from a line like "Preview: Fontsize 20.74pt"
-# Use grep for speed and because it gives an error if the line is not found.
+# Use grep for speed and because it gives an error if the line is
+# not found.
 LINE=`grep 'Preview: Fontsize' ${LOGFILE}`
 if [ $? -ne 0 ]; then
        echo "Failed: grep 'Preview: Fontsize' ${LOGFILE}"
        REQUIRED_VERSION
        BAIL_OUT
 fi
-# Use "" quotes in the echo to preserve newlines (technically IFS separators).
-# The sed script strips out everything that won't form a decimal number from the
-# line. It bails out after the first match has been made in case there are
-# multiple lines "Preview: Fontsize". (There shouldn't be.)
+# The sed script strips out everything that won't form a decimal number
+# from the line. It bails out after the first match has been made in
+# case there are multiple lines "Preview: Fontsize". (There shouldn't
+# be.)
+# Note: use "" quotes in the echo to preserve newlines.
 LATEXFONT=`echo "${LINE}" | sed 's/[^0-9\.]//g; 1q'`
 
-# 2. Extract magnification from a line like "Preview: Magnification 2074"
+# 2. Extract magnification from a line like
+# "Preview: Magnification 2074"
 # If no such line found, default to MAGNIFICATION=1000.
 LINE=`grep 'Preview: Magnification' ${LOGFILE}`
 if [ $? -ne 0 ]; then
        MAGNIFICATION=1000
 else
-       # The sed script strips out everything that won't form an /integer/.
+       # Strip out everything that won't form an /integer/.
        MAGNIFICATION=`echo "${LINE}" | sed 's/[^0-9]//g; 1q'`
 fi
 
 # 3. Compute resolution.
 # "bc" allows floating-point arithmetic, unlike "expr" or "dc".
 RESOLUTION=`echo "scale=2; \
-               ${SCALEFACTOR} * (10/${LATEXFONT}) * (1000/${MAGNIFICATION})" \
-               | bc`
+       ${SCALEFACTOR} * (10/${LATEXFONT}) * (1000/${MAGNIFICATION})" \
+       | bc`
 
 # DVI -> PostScript
 dvips -o ${PSFILE} ${DVIFILE}
@@ -140,10 +167,11 @@ if [ $? -ne 0 ]; then
 fi
 
 # PostScript -> Bitmap files
-# Older versions of gs have problems with a large degree of anti-aliasing
-# at high resolutions
+# Older versions of gs have problems with a large degree of
+# anti-aliasing at high resolutions
 
-# test expects integer arguments. ${RESOLUTION} may be a float. Truncate it.
+# test expects integer arguments.
+# ${RESOLUTION} may be a float. Truncate it.
 INT_RESOLUTION=`echo "${RESOLUTION} / 1" | bc`
 
 ALPHA=4
@@ -152,9 +180,9 @@ if [ ${INT_RESOLUTION} -gt 150 ]; then
 fi
 
 gs -q -dNOPAUSE -dBATCH -dSAFER \
-    -sDEVICE=${GSDEVICE} -sOutputFile=${BASE}%d.${GSSUFFIX} \
-    -dGraphicsAlphaBit=${ALPHA} -dTextAlphaBits=${ALPHA} -r${RESOLUTION} \
-    ${PSFILE}
+       -sDEVICE=${GSDEVICE} -sOutputFile=${BASE}%d.${GSSUFFIX} \
+       -dGraphicsAlphaBit=${ALPHA} -dTextAlphaBits=${ALPHA} \
+       -r${RESOLUTION} ${PSFILE}
 
 if [ $? -ne 0 ]; then
        echo "Failed: gs ${PSFILE}"
@@ -163,6 +191,6 @@ fi
 
 # All has been successful, so remove everything except the bitmap files
 # and the metrics file.
-FILES=`ls ${BASE}* | \
-       sed -e "/${BASE}.metrics/d" -e "/${BASE}\([0-9]*\).${GSSUFFIX}/d"`
+FILES=`ls ${BASE}* | sed -e "/${BASE}.metrics/d" \
+                        -e "/${BASE}\([0-9]*\).${GSSUFFIX}/d"`
 rm -f ${FILES} texput.log