]> git.lyx.org Git - features.git/commitdiff
J�rgen S's fix to bug 1817.
authorAngus Leeming <leeming@lyx.org>
Wed, 21 Sep 2005 09:22:18 +0000 (09:22 +0000)
committerAngus Leeming <leeming@lyx.org>
Wed, 21 Sep 2005 09:22:18 +0000 (09:22 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10468 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ChangeLog
lib/scripts/legacy_lyxpreview2ppm.py
lib/scripts/lyxpreview2bitmap.py

index 41460d829947de0d73c1d638fef9108af2a8ad28..f621ae136fdba669c814c9f268a058059c1a0d51 100644 (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>
 
        * configure.py: add Bo Peng's experimental Python script to
index 3bf1de27c12894a455121c0dd67cd96f9b6e8fe0..b3b743a4bae4075837c90f8ecf9d0bada8cd314a 100644 (file)
@@ -91,14 +91,22 @@ def extract_metrics_info(log_file, metrics_file):
                 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
 
-                    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:
                 tp_descent = string.atof(match.group(2))
index bf13261d3e80a451d766f0452bab89a39941d204..f0af3babf8b89f84ac2805a74c03a3ce31b83974 100755 (executable)
@@ -91,9 +91,15 @@ def extract_metrics_info(dvipng_stdout, metrics_file):
         # 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