]> git.lyx.org Git - features.git/commitdiff
Fix bug #2200 (The size of previewed images should be independent of the latex font...
authorEnrico Forestieri <forenr@lyx.org>
Wed, 11 May 2011 11:48:20 +0000 (11:48 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Wed, 11 May 2011 11:48:20 +0000 (11:48 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38701 a592a061-630c-0410-9148-cb99ea01b6c8

lib/scripts/lyxpreview-lytex2bitmap.py
lib/scripts/lyxpreview2bitmap.py

index 0666593790dceaac8c85fb69ee80d545b551b292..259c95eaee15a82acbd24c41030baa2537b15c3c 100755 (executable)
@@ -148,6 +148,27 @@ def color_pdf(latex_file, bg_color, fg_color):
     return success
 
 
+def fix_latex_file(latex_file):
+    documentclass_re = re.compile("(\\\\documentclass\[)(1[12]pt,)(.+)")
+
+    tmp = mkstemp()
+
+    changed = 0
+    for line in open(latex_file, 'r').readlines():
+        match = documentclass_re.match(line)
+        if match == None:
+            tmp.write(line)
+            continue
+
+        changed = 1
+        tmp.write("%s%s\n" % (match.group(1), match.group(3)))
+
+    if changed:
+        copyfileobj(tmp, open(latex_file,"wb"), 1)
+
+    return
+
+
 def convert_to_ppm_format(pngtopnm, basename):
     png_file_re = re.compile("\.png$")
 
@@ -191,6 +212,9 @@ def main(argv):
 
     lilypond_book = find_exe_or_terminate(["lilypond-book"], path)
 
+    # Omit font size specification in latex file.
+    fix_latex_file(latex_file)
+
     # Make a copy of the latex file
     lytex_file = latex_file_re.sub(".lytex", latex_file)
     shutil.copyfile(latex_file, lytex_file)
index 0468b2b24a4c527ea67ac5b554ddc590f6f363a3..d75dc069b25d9079a70ecaefa874714ee92ac483 100755 (executable)
@@ -167,6 +167,27 @@ def color_pdf(latex_file, bg_color, fg_color):
     return success
 
 
+def fix_latex_file(latex_file):
+    documentclass_re = re.compile("(\\\\documentclass\[)(1[12]pt,)(.+)")
+
+    tmp = mkstemp()
+
+    changed = 0
+    for line in open(latex_file, 'r').readlines():
+        match = documentclass_re.match(line)
+        if match == None:
+            tmp.write(line)
+            continue
+
+        changed = 1
+        tmp.write("%s%s\n" % (match.group(1), match.group(3)))
+
+    if changed:
+        copyfileobj(tmp, open(latex_file,"wb"), 1)
+
+    return
+
+
 def convert_to_ppm_format(pngtopnm, basename):
     png_file_re = re.compile("\.png$")
 
@@ -288,6 +309,9 @@ def main(argv):
     else:
         latex = find_exe_or_terminate(["latex", "pplatex", "platex", "latex2e"], path)
 
+    # Omit font size specification in latex file.
+    fix_latex_file(latex_file)
+
     # This can go once dvipng becomes widespread.
     dvipng = find_exe(["dvipng"], path)
     if dvipng == None: