Juergen Spitzmueller wrote: > > Thanks for the explanation. I think that this should fix things properly. > > José can advise on whether "float(ascent)" will work in Python 1.5.2. > > Hm, either I'm not testing the right file, or things haven't changed...
Actually, I was closer than I thought ;-) There's also some frac calculation done in lyxpreview2bitmap.py, and incorporation your changes there fixes the bug. Attached a patch with the changes in both files. The other patch has a change in math_hullinset that does suppress preview at least for empty, non nested inlineinsets, maybe it can be used for a start. Angus, if you got the time (and LGBJM agree), please feel free to shove the thing in. I'll be away for a few days, and the credits go to you anyway. Jürgen
Index: math_hullinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_hullinset.C,v retrieving revision 1.179 diff -u -r1.179 math_hullinset.C --- math_hullinset.C 18 Jul 2005 17:12:28 -0000 1.179 +++ math_hullinset.C 21 Sep 2005 07:38:50 -0000 @@ -374,7 +374,10 @@ void MathHullInset::addPreview(lyx::graphics::PreviewLoader & ploader) const { if (RenderPreview::status() == LyXRC::PREVIEW_ON) { - string const snippet = latex_string(*this); + string snippet; + // don't preview if there's no content + if (!cell(0).empty()) + snippet = latex_string(*this); preview_->addPreview(snippet, ploader); } } @@ -384,7 +387,10 @@ { if (RenderPreview::status() == LyXRC::PREVIEW_ON) { Buffer const & buffer = cur.buffer(); - string const snippet = latex_string(*this); + string snippet; + // don't preview if there's no content + if (!cell(0).empty()) + snippet = latex_string(*this); preview_->addPreview(snippet, buffer); preview_->startLoading(buffer); }
Index: scripts/legacy_lyxpreview2ppm.py =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/scripts/legacy_lyxpreview2ppm.py,v retrieving revision 1.9 diff -u -r1.9 legacy_lyxpreview2ppm.py --- scripts/legacy_lyxpreview2ppm.py 16 Jun 2005 13:15:09 -0000 1.9 +++ scripts/legacy_lyxpreview2ppm.py 21 Sep 2005 07:35:14 -0000 @@ -91,14 +91,22 @@ error("Unexpected data in %s\n%s" % (log_file, line)) if snippet: - ascent = string.atof(match.group(2)) + tp_ascent - descent = string.atof(match.group(3)) - tp_descent + ascent = string.atoi(match.group(2)) + descent = string.atoi(match.group(3)) frac = 0.5 - if abs(ascent + descent) > 0.1: - frac = ascent / (ascent + descent) + if ascent > 0 and descent > 0: + ascent = float(ascent) + tp_ascent + descent = float(descent) - tp_descent + + if abs(ascent + descent) > 0.1: + frac = ascent / (ascent + descent) + + # Sanity check + if frac < 0 or frac > 1: + frac = 0.5 - metrics.write("Snippet %s %f\n" % (match.group(1), frac)) + metrics.write("Snippet %s %f\n" % (match.group(1), frac)) else: tp_descent = string.atof(match.group(2)) Index: scripts/lyxpreview2bitmap.py =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/scripts/lyxpreview2bitmap.py,v retrieving revision 1.9 diff -u -r1.9 lyxpreview2bitmap.py --- scripts/lyxpreview2bitmap.py 8 May 2005 14:11:39 -0000 1.9 +++ scripts/lyxpreview2bitmap.py 21 Sep 2005 07:35:14 -0000 @@ -91,9 +91,15 @@ # Calculate the 'ascent fraction'. descent = string.atof(match.group(2)) ascent = string.atof(match.group(3)) + frac = 0.5 - if abs(ascent + descent) > 0.1: - frac = ascent / (ascent + descent) + if ascent > 0 and descent > 0: + if abs(ascent + descent) > 0.1: + frac = ascent / (ascent + descent) + + # Sanity check + if frac < 0 or frac > 1: + frac = 0.5 metrics.write("Snippet %s %f\n" % (match.group(1), frac)) pos = match.end(3) + 2