]> git.lyx.org Git - features.git/commitdiff
- Preamble.cpp: handle \setxxxlanguage with options
authorUwe Stöhr <uwestoehr@lyx.org>
Fri, 22 Jun 2012 15:19:46 +0000 (17:19 +0200)
committerUwe Stöhr <uwestoehr@lyx.org>
Fri, 22 Jun 2012 15:19:46 +0000 (17:19 +0200)
- text.cpp: handle the commands \textxxx with options
- XeTeX-polyglossia.tex: add 2 more testcases

src/tex2lyx/Preamble.cpp
src/tex2lyx/test/XeTeX-polyglossia.tex
src/tex2lyx/text.cpp

index a0210d17956a6932bb18d16ef169f3f9441d9110..8309b6bd7c8beabbdf4d310e8a2d74b6a80410e6 100644 (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
index 81a2258814a924b140bf7353c4ea94059c33dad4..99a185b44bd7a22f4255a86f083f0eeb1fb360a0 100644 (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}
 \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}%
 
index 3fe7dbd76a21258974c1c09b70f340f3c0d30b84..7b4970f84e6d80af73542ec7408b45bd1750b730 100644 (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);
                }