From 73f0f4dd6c82bca169e686c0a5d5bc7b410aae00 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Fri, 22 Jun 2012 17:19:46 +0200 Subject: [PATCH] - Preamble.cpp: handle \setxxxlanguage with options - text.cpp: handle the commands \textxxx with options - XeTeX-polyglossia.tex: add 2 more testcases --- src/tex2lyx/Preamble.cpp | 24 +++++++++++++++++++----- src/tex2lyx/test/XeTeX-polyglossia.tex | 6 ++---- src/tex2lyx/text.cpp | 7 ++++++- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index a0210d1795..8309b6bd7c 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -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_seppackage_mid_seppackage_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 diff --git a/src/tex2lyx/test/XeTeX-polyglossia.tex b/src/tex2lyx/test/XeTeX-polyglossia.tex index 81a2258814..99a185b44b 100644 --- a/src/tex2lyx/test/XeTeX-polyglossia.tex +++ b/src/tex2lyx/test/XeTeX-polyglossia.tex @@ -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}% diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 3fe7dbd76a..7b4970f84e 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -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); } -- 2.39.2