mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-04 16:42:57 +00:00
* enable instant preview with XeTeX (requires preview-latex v.11.86) [bug #5577]
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33554 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
8207c3e82a
commit
c2ef290547
@ -30,13 +30,14 @@
|
|||||||
# Example usage:
|
# Example usage:
|
||||||
# lyxpreview2bitmap.py png 0lyxpreview.tex 128 000000 faf0e6
|
# lyxpreview2bitmap.py png 0lyxpreview.tex 128 000000 faf0e6
|
||||||
|
|
||||||
# This script takes five arguments:
|
# This script takes six arguments:
|
||||||
# FORMAT: The desired output format. Either 'png' or 'ppm'.
|
# FORMAT: The desired output format. Either 'png' or 'ppm'.
|
||||||
# TEXFILE: the name of the .tex file to be converted.
|
# TEXFILE: the name of the .tex file to be converted.
|
||||||
# DPI: a scale factor, used to ascertain the resolution of the
|
# DPI: a scale factor, used to ascertain the resolution of the
|
||||||
# generated image which is then passed to gs.
|
# generated image which is then passed to gs.
|
||||||
# FG_COLOR: the foreground color as a hexadecimal string, eg '000000'.
|
# FG_COLOR: the foreground color as a hexadecimal string, eg '000000'.
|
||||||
# BG_COLOR: the background color as a hexadecimal string, eg 'faf0e6'.
|
# BG_COLOR: the background color as a hexadecimal string, eg 'faf0e6'.
|
||||||
|
# CONVERTER: the converter (optional). Default is latex.
|
||||||
|
|
||||||
# Decomposing TEXFILE's name as DIR/BASE.tex, this script will,
|
# Decomposing TEXFILE's name as DIR/BASE.tex, this script will,
|
||||||
# if executed successfully, leave in DIR:
|
# if executed successfully, leave in DIR:
|
||||||
@ -154,7 +155,7 @@ def convert_to_ppm_format(pngtopnm, basename):
|
|||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
# Parse and manipulate the command line arguments.
|
# Parse and manipulate the command line arguments.
|
||||||
if len(argv) != 6:
|
if len(argv) != 6 and len(argv) != 7:
|
||||||
error(usage(argv[0]))
|
error(usage(argv[0]))
|
||||||
|
|
||||||
output_format = string.lower(argv[1])
|
output_format = string.lower(argv[1])
|
||||||
@ -171,7 +172,10 @@ def main(argv):
|
|||||||
|
|
||||||
# External programs used by the script.
|
# External programs used by the script.
|
||||||
path = string.split(os.environ["PATH"], os.pathsep)
|
path = string.split(os.environ["PATH"], os.pathsep)
|
||||||
latex = find_exe_or_terminate(["latex", "pplatex", "platex", "latex2e"], path)
|
if len(argv) == 7:
|
||||||
|
latex = argv[6]
|
||||||
|
else:
|
||||||
|
latex = find_exe_or_terminate(["latex", "pplatex", "platex", "latex2e"], path)
|
||||||
|
|
||||||
# This can go once dvipng becomes widespread.
|
# This can go once dvipng becomes widespread.
|
||||||
dvipng = find_exe(["dvipng"], path)
|
dvipng = find_exe(["dvipng"], path)
|
||||||
@ -179,7 +183,7 @@ def main(argv):
|
|||||||
# The data is input to legacy_conversion in as similar
|
# The data is input to legacy_conversion in as similar
|
||||||
# as possible a manner to that input to the code used in
|
# as possible a manner to that input to the code used in
|
||||||
# LyX 1.3.x.
|
# LyX 1.3.x.
|
||||||
vec = [ argv[0], argv[2], argv[3], argv[1], argv[4], argv[5] ]
|
vec = [ argv[0], argv[2], argv[3], argv[1], argv[4], argv[5], argv[6] ]
|
||||||
return legacy_conversion(vec)
|
return legacy_conversion(vec)
|
||||||
|
|
||||||
pngtopnm = ""
|
pngtopnm = ""
|
||||||
@ -198,6 +202,11 @@ def main(argv):
|
|||||||
warning("%s failed to compile %s" \
|
warning("%s failed to compile %s" \
|
||||||
% (os.path.basename(latex), latex_file))
|
% (os.path.basename(latex), latex_file))
|
||||||
|
|
||||||
|
if latex == "xelatex":
|
||||||
|
warning("Using XeTeX")
|
||||||
|
# FIXME: skip unnecessary dvips trial in legacy_conversion_step2
|
||||||
|
return legacy_conversion_step2(latex_file, dpi, output_format)
|
||||||
|
|
||||||
# Run the dvi file through dvipng.
|
# Run the dvi file through dvipng.
|
||||||
dvi_file = latex_file_re.sub(".dvi", latex_file)
|
dvi_file = latex_file_re.sub(".dvi", latex_file)
|
||||||
dvipng_call = '%s -Ttight -depth -height -D %d -fg "%s" -bg "%s" "%s"' \
|
dvipng_call = '%s -Ttight -depth -height -D %d -fg "%s" -bg "%s" "%s"' \
|
||||||
@ -207,6 +216,7 @@ def main(argv):
|
|||||||
if dvipng_status != None:
|
if dvipng_status != None:
|
||||||
warning("%s failed to generate images from %s ... looking for PDF" \
|
warning("%s failed to generate images from %s ... looking for PDF" \
|
||||||
% (os.path.basename(dvipng), dvi_file))
|
% (os.path.basename(dvipng), dvi_file))
|
||||||
|
# FIXME: skip unnecessary dvips trial in legacy_conversion_step2
|
||||||
return legacy_conversion_step2(latex_file, dpi, output_format)
|
return legacy_conversion_step2(latex_file, dpi, output_format)
|
||||||
|
|
||||||
# Extract metrics info from dvipng_stdout.
|
# Extract metrics info from dvipng_stdout.
|
||||||
|
@ -592,6 +592,8 @@ void PreviewLoader::Impl::startLoading()
|
|||||||
<< int(font_scaling_factor) << ' '
|
<< int(font_scaling_factor) << ' '
|
||||||
<< theApp()->hexName(PreviewLoader::foregroundColor()) << ' '
|
<< theApp()->hexName(PreviewLoader::foregroundColor()) << ' '
|
||||||
<< theApp()->hexName(PreviewLoader::backgroundColor());
|
<< theApp()->hexName(PreviewLoader::backgroundColor());
|
||||||
|
if (buffer_.params().useXetex)
|
||||||
|
cs << " xelatex";
|
||||||
|
|
||||||
string const command = libScriptSearch(cs.str());
|
string const command = libScriptSearch(cs.str());
|
||||||
|
|
||||||
@ -704,18 +706,28 @@ void PreviewLoader::Impl::dumpPreamble(odocstream & os) const
|
|||||||
// Use the preview style file to ensure that each snippet appears on a
|
// Use the preview style file to ensure that each snippet appears on a
|
||||||
// fresh page.
|
// fresh page.
|
||||||
// Also support PDF output (automatically generated e.g. when
|
// Also support PDF output (automatically generated e.g. when
|
||||||
// \usepackage[pdftex]{hyperref} is used.
|
// \usepackage[pdftex]{hyperref} is used and XeTeX.
|
||||||
os << "\n"
|
os << "\n"
|
||||||
|
<< "\\newif\\ifxetex\n"
|
||||||
|
<< "\\expandafter\\ifx\\csname XeTeXrevision\\endcsname\\relax\n"
|
||||||
|
<< " \\xetexfalse\n"
|
||||||
|
<< "\\else\n"
|
||||||
|
<< " \\xetextrue\n"
|
||||||
|
<< "\\fi\n"
|
||||||
<< "\\newif\\ifpdf\n"
|
<< "\\newif\\ifpdf\n"
|
||||||
<< "\\ifx\\pdfoutput\\undefined\n"
|
<< "\\ifx\\pdfoutput\\undefined\n"
|
||||||
<< "\\else\\ifx\\pdfoutput\\relax\n"
|
<< "\\else\\ifx\\pdfoutput\\relax\n"
|
||||||
<< "\\else\\ifnum0=\\pdfoutput\n"
|
<< "\\else\\ifnum0=\\pdfoutput\n"
|
||||||
<< "\\else\\pdftrue\\fi\\fi\\fi\n"
|
<< "\\else\\pdftrue\\fi\\fi\\fi\n"
|
||||||
|
<< "\\ifxetex\n"
|
||||||
|
<< " \\usepackage[active,delayed,tightpage,showlabels,lyx,xetex]{preview}\n"
|
||||||
|
<< "\\else\n"
|
||||||
<< "\\ifpdf\n"
|
<< "\\ifpdf\n"
|
||||||
<< " \\usepackage[active,delayed,tightpage,showlabels,lyx,pdftex]{preview}\n"
|
<< " \\usepackage[active,delayed,tightpage,showlabels,lyx,pdftex]{preview}\n"
|
||||||
<< "\\else\n"
|
<< "\\else\n"
|
||||||
<< " \\usepackage[active,delayed,showlabels,lyx,dvips]{preview}\n"
|
<< " \\usepackage[active,delayed,showlabels,lyx,dvips]{preview}\n"
|
||||||
<< "\\fi\n"
|
<< "\\fi\n"
|
||||||
|
<< "\\fi\n"
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user