J�rgen S's fix to bug 1817.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10468 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2005-09-21 09:22:18 +00:00
parent 53a118caea
commit c302740b9b
3 changed files with 28 additions and 7 deletions

View File

@ -1,3 +1,10 @@
2005-09-21 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* scripts/legacy_lyxpreview2ppm.py:
* scripts/lyxpreview2bitmap.py: ensure that the metrics file
contains sensible fractional ascent data if the extracted
ascent or descent data is zero.
2005-09-18 Angus Leeming <leeming@lyx.org> 2005-09-18 Angus Leeming <leeming@lyx.org>
* configure.py: add Bo Peng's experimental Python script to * configure.py: add Bo Peng's experimental Python script to

View File

@ -91,14 +91,22 @@ def extract_metrics_info(log_file, metrics_file):
error("Unexpected data in %s\n%s" % (log_file, line)) error("Unexpected data in %s\n%s" % (log_file, line))
if snippet: if snippet:
ascent = string.atof(match.group(2)) + tp_ascent ascent = string.atoi(match.group(2))
descent = string.atof(match.group(3)) - tp_descent descent = string.atoi(match.group(3))
frac = 0.5 frac = 0.5
if abs(ascent + descent) > 0.1: if ascent > 0 and descent > 0:
frac = ascent / (ascent + descent) ascent = float(ascent) + tp_ascent
descent = float(descent) - tp_descent
metrics.write("Snippet %s %f\n" % (match.group(1), frac)) 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))
else: else:
tp_descent = string.atof(match.group(2)) tp_descent = string.atof(match.group(2))

View File

@ -91,9 +91,15 @@ def extract_metrics_info(dvipng_stdout, metrics_file):
# Calculate the 'ascent fraction'. # Calculate the 'ascent fraction'.
descent = string.atof(match.group(2)) descent = string.atof(match.group(2))
ascent = string.atof(match.group(3)) ascent = string.atof(match.group(3))
frac = 0.5 frac = 0.5
if abs(ascent + descent) > 0.1: if ascent > 0 and descent > 0:
frac = ascent / (ascent + 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))
pos = match.end(3) + 2 pos = match.end(3) + 2