]> git.lyx.org Git - lyx.git/blobdiff - lib/scripts/legacy_lyxpreview2ppm.py
*lib/scripts/layout2layout.py: Fix section labelling
[lyx.git] / lib / scripts / legacy_lyxpreview2ppm.py
index a36466d801441acc06d4240a0e2a24b6bc20b641..f887b5c4dce96f95cfc027a034d62f1a8b49a0ee 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))
@@ -228,7 +236,7 @@ def legacy_conversion(argv):
     path = string.split(os.environ["PATH"], os.pathsep)
     latex   = find_exe_or_terminate(["pplatex", "latex2e", "latex"], path)
     dvips   = find_exe_or_terminate(["dvips"], path)
-    gs      = find_exe_or_terminate(["gswin32", "gs"], path)
+    gs      = find_exe_or_terminate(["gswin32c", "gs"], path)
     pnmcrop = find_exe(["pnmcrop"], path)
 
     # Move color information into the latex file.