mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
* lyxpreview-lytex2bitmap.py: port color changes from lyxpreview2bitmap.py
Why do we need two separate files actually? The difference of these two files is minimal. Couldn't we introduce a further option for "lytex" mode in lyxpreview2bitmap.py instead? This would significantly lower the maintenance burden. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38120 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fe76628b9e
commit
9071f82080
@ -112,11 +112,15 @@ def extract_metrics_info(dvipng_stdout):
|
||||
return results
|
||||
|
||||
|
||||
def color_pdf(latex_file, bg_color):
|
||||
use_preview_pdf_re = re.compile("(\s*\\\\usepackage\[[^]]+)(pdftex\]{preview})")
|
||||
def color_pdf(latex_file, bg_color, fg_color):
|
||||
use_preview_pdf_re = re.compile("(\s*\\\\usepackage\[[^]]+)(pdftex|xetex\]{preview})")
|
||||
|
||||
tmp = mkstemp()
|
||||
|
||||
|
||||
fg = ""
|
||||
if fg_color != "0.000000,0.000000,0.000000":
|
||||
fg = ' \\AtBeginDocument{\\let\\oldpreview\\preview\\renewcommand\\preview{\\oldpreview\\color[rgb]{%s}}}\n' % (fg_color)
|
||||
|
||||
success = 0
|
||||
try:
|
||||
for line in open(latex_file, 'r').readlines():
|
||||
@ -127,8 +131,9 @@ def color_pdf(latex_file, bg_color):
|
||||
success = 1
|
||||
tmp.write(" \\usepackage{color}\n" \
|
||||
" \\pagecolor[rgb]{%s}\n" \
|
||||
"%s" \
|
||||
"%s\n" \
|
||||
% (bg_color, match.group()))
|
||||
% (bg_color, fg, match.group()))
|
||||
continue
|
||||
|
||||
except:
|
||||
@ -174,6 +179,7 @@ def main(argv):
|
||||
fg_color = make_texcolor(argv[4], False)
|
||||
bg_color = make_texcolor(argv[5], False)
|
||||
|
||||
fg_color_gr = make_texcolor(argv[4], True)
|
||||
bg_color_gr = make_texcolor(argv[5], True)
|
||||
|
||||
# External programs used by the script.
|
||||
@ -217,7 +223,7 @@ def main(argv):
|
||||
pngtopnm = find_exe_or_terminate(["pngtopnm"], path)
|
||||
|
||||
# Move color information for PDF into the latex file.
|
||||
if not color_pdf(latex_file, bg_color_gr):
|
||||
if not color_pdf(latex_file, bg_color_gr, fg_color_gr):
|
||||
error("Unable to move color info into the latex file")
|
||||
|
||||
# Compile the latex file.
|
||||
|
Loading…
Reference in New Issue
Block a user