]> git.lyx.org Git - features.git/blobdiff - lib/scripts/lyxpreview2bitmap.py
J�rgen S's fix to bug 1817.
[features.git] / lib / scripts / lyxpreview2bitmap.py
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