- Preamble.cpp: handle \setxxxlanguage with options

- text.cpp: handle the commands \textxxx with options
- XeTeX-polyglossia.tex: add 2 more testcases
This commit is contained in:
Uwe Stöhr 2012-06-22 17:19:46 +02:00
parent 79352b9882
commit 73f0f4dd6c
3 changed files with 27 additions and 10 deletions

View File

@ -174,10 +174,11 @@ const char * const known_xetex_packages[] = {"arabxetex", "fixlatvian",
/// packages that are automatically skipped if loaded by LyX
const char * const known_lyx_packages[] = {"amsbsy", "amsmath", "amssymb",
"amstext", "amsthm", "array", "booktabs", "calc", "color", "float",
"amstext", "amsthm", "array", "booktabs", "calc", "color", "float", "fontspec",
"graphicx", "hhline", "ifthen", "longtable", "makeidx", "multirow",
"nomencl", "pdfpages", "rotating", "rotfloat", "splitidx", "setspace",
"subscript", "textcomp", "ulem", "url", "varioref", "verbatim", "wrapfig", 0};
"subscript", "textcomp", "ulem", "url", "varioref", "verbatim", "wrapfig",
"xunicode", 0};
// codes used to remove packages that are loaded automatically by LyX.
// Syntax: package_beg_sep<name>package_mid_sep<package loading code>package_end_sep
@ -601,6 +602,7 @@ void Preamble::handle_package(Parser &p, string const & name,
if (is_known(name, known_xetex_packages)) {
xetex = true;
h_use_non_tex_fonts = "true";
registerAutomaticallyLoadedPackage("fontspec");
if (h_inputencoding == "auto")
p.setEncoding("utf8");
}
@ -694,6 +696,7 @@ void Preamble::handle_package(Parser &p, string const & name,
h_default_output_format = "pdf4";
h_use_non_tex_fonts = "true";
xetex = true;
registerAutomaticallyLoadedPackage("xunicode");
if (h_inputencoding == "auto")
p.setEncoding("utf8");
}
@ -1069,11 +1072,22 @@ void Preamble::parse(Parser & p, string const & forceclass,
else if (t.cs() == "pagestyle")
h_paperpagestyle = p.verbatim_item();
else if (t.cs() == "setdefaultlanguage")
else if (t.cs() == "setdefaultlanguage") {
// FIXME: we don't yet care about the option because LyX doesn't
// support this yet, see bug #8214
p.hasOpt() ? p.getOpt() : string();
h_language = p.verbatim_item();
}
else if (t.cs() == "setotherlanguage")
;
else if (t.cs() == "setotherlanguage") {
// FIXME: we don't yet care about the option because LyX doesn't
// support this yet, see bug #8214
p.hasOpt() ? p.getOpt() : string();
p.verbatim_item();
// FIXME: there can be multiple occurences of
// \setotherlanguage, we need to handle them all not only the
// first one
}
else if (t.cs() == "setmainfont") {
// we don't care about the option

View File

@ -1,5 +1,3 @@
%% LyX 2.1.0svn created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[albanian]{article}
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{Aharoni}
@ -10,13 +8,13 @@
\setdefaultlanguage{coptic}
\setotherlanguage{albanian}
\setotherlanguage{divehi}
\setotherlanguage{greek}
\setotherlanguage[variant=monotonic]{greek}
\setotherlanguage{syriac}
\begin{document}
\part{df}
1 Coptic \textgreek{Greek} Coptic
1 Coptic \textgreek[variant=ancient]{ancient Greek} Coptic
\begin{albanian}%

View File

@ -3471,7 +3471,12 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
else if (is_known(t.cs().substr(4, string::npos), polyglossia_languages)) {
// scheme is \textLANGUAGE{text} where LANGUAGE is in polyglossia_languages[]
string const lang = polyglossia2lyx(t.cs().substr(4, string::npos));
parse_text_attributes(p, os, FLAG_ITEM, outer,
// FIXME: we have to output the whole command if it has an option
// because lyX doesn't support this yet, see bug #8214
if (p.hasOpt())
handle_ert(os, t.asInput() + p.getOpt(), context);
else
parse_text_attributes(p, os, FLAG_ITEM, outer,
context, "\\lang",
context.font.language, lang);
}