mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-24 17:09:41 +00:00
Simplify code by telling gs to output bitmap files as %d, not %Nd where
N is some painfully specified integer. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5204 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
952b6a424c
commit
63dca538e9
@ -1,3 +1,8 @@
|
|||||||
|
2002-09-04 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
|
* scripts/lyxpreview2ppm.sh: output gs filenames as %d, not %Nd where N
|
||||||
|
is some input value.
|
||||||
|
|
||||||
2002-09-04 Lars Gullik Bjønnes <larsbj@gullik.net>
|
2002-09-04 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||||
|
|
||||||
* layouts/stdclass.inc: include stdfloats.h
|
* layouts/stdclass.inc: include stdfloats.h
|
||||||
|
@ -14,17 +14,15 @@
|
|||||||
|
|
||||||
# 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:
|
# This script takes two arguments:
|
||||||
# TEXFILE: the name of the .tex file to be converted.
|
# TEXFILE: the name of the .tex file to be converted.
|
||||||
# SCALEFACTOR: scale factor, used to ascertain the resolution of the
|
# SCALEFACTOR: a scale factor, used to ascertain the resolution of the
|
||||||
# generated image which is then passed to gs.
|
# generated image which is then passed to gs.
|
||||||
# NDIGITS: the number of digits in the filenames generated by gs,
|
|
||||||
# ${BASE}%0${NDIGITS}d.ppm.
|
|
||||||
|
|
||||||
# If successful, this script will leave in dir ${DIR}:
|
# If successful, this script will leave in dir ${DIR}:
|
||||||
# ${BASE}[0-9]\{${NDIGITS}\}.ppm: a (possibly large) number of image files.
|
# ${BASE}\([0-9]*\).ppm: a (possibly large) number of image files.
|
||||||
# ${BASE}.metrics: a file containing info needed by LyX to
|
# ${BASE}.metrics: a file containing info needed by LyX to position the
|
||||||
# position the images correctly on the screen.
|
# images correctly on the screen.
|
||||||
# All other files ${BASE}* will be deleted.
|
# All other files ${BASE}* will be deleted.
|
||||||
|
|
||||||
# Three helper functions.
|
# Three helper functions.
|
||||||
@ -49,7 +47,7 @@ REQUIRED_VERSION () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Preliminary check.
|
# Preliminary check.
|
||||||
if [ $# -ne 3 ]; then
|
if [ $# -ne 2 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -63,7 +61,6 @@ DIR=`dirname $1`
|
|||||||
BASE=`basename $1 .tex`
|
BASE=`basename $1 .tex`
|
||||||
|
|
||||||
SCALEFACTOR=$2
|
SCALEFACTOR=$2
|
||||||
NDIGITS=$3
|
|
||||||
|
|
||||||
TEXFILE=${BASE}.tex
|
TEXFILE=${BASE}.tex
|
||||||
LOGFILE=${BASE}.log
|
LOGFILE=${BASE}.log
|
||||||
@ -139,7 +136,7 @@ if [ ${INT_RESOLUTION} -gt 150 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
gs -q -dNOPAUSE -dBATCH -dSAFER \
|
gs -q -dNOPAUSE -dBATCH -dSAFER \
|
||||||
-sDEVICE=pnmraw -sOutputFile=${BASE}%0${NDIGITS}d.ppm \
|
-sDEVICE=pnmraw -sOutputFile=${BASE}%d.ppm \
|
||||||
-dGraphicsAlphaBit=${ALPHA} -dTextAlphaBits=${ALPHA} -r${RESOLUTION} \
|
-dGraphicsAlphaBit=${ALPHA} -dTextAlphaBits=${ALPHA} -r${RESOLUTION} \
|
||||||
${PSFILE}
|
${PSFILE}
|
||||||
|
|
||||||
@ -151,5 +148,5 @@ fi
|
|||||||
# All has been successful, so remove everything except the bitmap files
|
# All has been successful, so remove everything except the bitmap files
|
||||||
# and the metrics file.
|
# and the metrics file.
|
||||||
FILES=`ls ${BASE}* | \
|
FILES=`ls ${BASE}* | \
|
||||||
sed -e "/${BASE}.metrics/d" -e "/${BASE}[0-9]\{${NDIGITS}\}.ppm/d"`
|
sed -e "/${BASE}.metrics/d" -e "/${BASE}\([0-9]*\).ppm/d"`
|
||||||
rm -f ${FILES}
|
rm -f ${FILES} texput.log
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2002-09-04 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
|
* PreviewLoader.C: remove this ndigits stuff as an unnecessary extra.
|
||||||
|
|
||||||
2002-09-03 Angus Leeming <leeming@lyx.org>
|
2002-09-03 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
* PreviewLoader.C: fix crash reported by Norbert Koksch when
|
* PreviewLoader.C: fix crash reported by Norbert Koksch when
|
||||||
|
@ -86,16 +86,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Given a base-10 number return the number of digits needed to store it.
|
|
||||||
// Eg 2 requires 1 digit, 22 requires 2 digits and 999 requires 3 digits.
|
|
||||||
// Note that André suggests just returning '12' here...
|
|
||||||
int ndigits(int /*num*/)
|
|
||||||
{
|
|
||||||
//return 1 + int(std::log10(double(num)));
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Store info on a currently executing, forked process.
|
/// Store info on a currently executing, forked process.
|
||||||
struct InProgress {
|
struct InProgress {
|
||||||
///
|
///
|
||||||
@ -256,18 +246,14 @@ namespace {
|
|||||||
|
|
||||||
struct IncrementedFileName {
|
struct IncrementedFileName {
|
||||||
IncrementedFileName(string const & to_format,
|
IncrementedFileName(string const & to_format,
|
||||||
string const & filename_base, int nd)
|
string const & filename_base)
|
||||||
: to_format_(to_format), base_(filename_base),
|
: to_format_(to_format), base_(filename_base), counter_(1)
|
||||||
ndigits_(nd), counter_(1)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
StrPair const operator()(string const & snippet)
|
StrPair const operator()(string const & snippet)
|
||||||
{
|
{
|
||||||
ostringstream os;
|
ostringstream os;
|
||||||
os << base_
|
os << base_ << counter_++ << "." << to_format_;
|
||||||
<< setfill('0') << setw(ndigits_) << counter_++
|
|
||||||
<< "." << to_format_;
|
|
||||||
|
|
||||||
string const file = os.str().c_str();
|
string const file = os.str().c_str();
|
||||||
|
|
||||||
return make_pair(snippet, file);
|
return make_pair(snippet, file);
|
||||||
@ -276,7 +262,6 @@ struct IncrementedFileName {
|
|||||||
private:
|
private:
|
||||||
string const & to_format_;
|
string const & to_format_;
|
||||||
string const & base_;
|
string const & base_;
|
||||||
int const ndigits_;
|
|
||||||
int counter_;
|
int counter_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -293,8 +278,7 @@ InProgress::InProgress(string const & filename_base,
|
|||||||
BitmapFile::iterator sit = snippets.begin();
|
BitmapFile::iterator sit = snippets.begin();
|
||||||
|
|
||||||
std::transform(pit, pend, sit,
|
std::transform(pit, pend, sit,
|
||||||
IncrementedFileName(to_format, filename_base,
|
IncrementedFileName(to_format, filename_base));
|
||||||
ndigits(int(snippets.size()))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -471,6 +455,9 @@ void PreviewLoader::Impl::startLoading()
|
|||||||
// such processes if it starts correctly.
|
// such processes if it starts correctly.
|
||||||
InProgress inprogress(filename_base, pending_, pconverter_->to);
|
InProgress inprogress(filename_base, pending_, pconverter_->to);
|
||||||
|
|
||||||
|
// clear pending_, so we're ready to start afresh.
|
||||||
|
pending_.clear();
|
||||||
|
|
||||||
// Output the LaTeX file.
|
// Output the LaTeX file.
|
||||||
string const latexfile = filename_base + ".tex";
|
string const latexfile = filename_base + ".tex";
|
||||||
|
|
||||||
@ -485,14 +472,10 @@ void PreviewLoader::Impl::startLoading()
|
|||||||
// The conversion command.
|
// The conversion command.
|
||||||
ostringstream cs;
|
ostringstream cs;
|
||||||
cs << pconverter_->command << " " << latexfile << " "
|
cs << pconverter_->command << " " << latexfile << " "
|
||||||
<< int(font_scaling_factor_) << " "
|
<< int(font_scaling_factor_);
|
||||||
<< ndigits(int(pending_.size()));
|
|
||||||
|
|
||||||
string const command = LibScriptSearch(cs.str().c_str());
|
string const command = LibScriptSearch(cs.str().c_str());
|
||||||
|
|
||||||
// clear pending_, so we're ready to start afresh.
|
|
||||||
pending_.clear();
|
|
||||||
|
|
||||||
// Initiate the conversion from LaTeX to bitmap images files.
|
// Initiate the conversion from LaTeX to bitmap images files.
|
||||||
Forkedcall::SignalTypePtr convert_ptr;
|
Forkedcall::SignalTypePtr convert_ptr;
|
||||||
convert_ptr.reset(new Forkedcall::SignalType);
|
convert_ptr.reset(new Forkedcall::SignalType);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user