]> git.lyx.org Git - features.git/commitdiff
Fix misparsing of \textgreek without polyglossia
authorGeorg Baum <baum@lyx.org>
Tue, 30 Dec 2014 16:44:08 +0000 (17:44 +0100)
committerGeorg Baum <baum@lyx.org>
Tue, 30 Dec 2014 16:44:08 +0000 (17:44 +0100)
This is the first part of bug #8553. \textgreek was interpreted as the
polyglossia version even if polyglossia was not used. Now it is not recognized
at all and converted to ERT, but this ensures at least correct LaTeX output.

src/tex2lyx/Preamble.cpp
src/tex2lyx/Preamble.h
src/tex2lyx/test/box-color-size-space-align.lyx.lyx
src/tex2lyx/text.cpp

index bb2ace3c24f22ef92c36655d122f23a906a8fb01..b4c8adcf0af915015f20c36deef8fbc60b2faf76 100644 (file)
@@ -306,7 +306,7 @@ const char * const Preamble::polyglossia_languages[] = {
 "irish", "portuges", "thai", "bahasai", "english", "italian", "romanian", "turkish",
 "bahasam", "esperanto", "lao", "russian", "turkmen", "basque", "estonian", "latin",
 "samin", "ukrainian", "bengali", "farsi", "latvian", "sanskrit", "tibetan", "urdu",
-"brazil", "brazilian", "finnish", "lithuanian", "scottish", "usorbian", "breton", 
+"brazil", "brazilian", "finnish", "lithuanian", "scottish", "usorbian", "breton",
 "french", "lsorbian", "serbian", "vietnamese", "bulgarian", "galician", "magyar",
 "slovak", "welsh", "catalan", "german", "malayalam", "slovenian", "coptic", "greek",
 "marathi", "spanish", "austrian",
@@ -332,6 +332,12 @@ const char * const Preamble::coded_polyglossia_languages[] = {
 "polutonikogreek", 0};
 
 
+bool Preamble::usePolyglossia() const
+{
+       return h_use_non_tex_fonts && h_language_package == "default";
+}
+
+
 bool Preamble::indentParagraphs() const
 {
        return h_paragraph_separation == "indent";
@@ -464,7 +470,7 @@ Preamble::Preamble() : one_language(true), explicit_babel(false),
        h_font_typewriter         = "default";
        h_font_math               = "auto";
        h_font_default_family     = "default";
-       h_use_non_tex_fonts       = "false";
+       h_use_non_tex_fonts       = false;
        h_font_sc                 = "false";
        h_font_osf                = "false";
        h_font_sf_scale           = "100";
@@ -662,7 +668,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";
+               h_use_non_tex_fonts = true;
                registerAutomaticallyLoadedPackage("fontspec");
                if (h_inputencoding == "auto")
                        p.setEncoding("UTF-8");
@@ -704,7 +710,7 @@ void Preamble::handle_package(Parser &p, string const & name,
                else if (opts == "osf")
                        h_font_osf = "true";
        }
-       
+
        if (name == "mathdesign") {
                if (opts.find("charter") != string::npos)
                        h_font_roman = "md-charter";
@@ -849,7 +855,7 @@ void Preamble::handle_package(Parser &p, string const & name,
        else if (name == "polyglossia") {
                h_language_package = "default";
                h_default_output_format = "pdf4";
-               h_use_non_tex_fonts = "true";
+               h_use_non_tex_fonts = true;
                xetex = true;
                registerAutomaticallyLoadedPackage("xunicode");
                if (h_inputencoding == "auto")
@@ -1127,7 +1133,7 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc)
           << "\\font_typewriter " << h_font_typewriter << "\n"
           << "\\font_math " << h_font_math << "\n"
           << "\\font_default_family " << h_font_default_family << "\n"
-          << "\\use_non_tex_fonts " << h_use_non_tex_fonts << "\n"
+          << "\\use_non_tex_fonts " << (h_use_non_tex_fonts ? "true" : "false") << '\n'
           << "\\font_sc " << h_font_sc << "\n"
           << "\\font_osf " << h_font_osf << "\n"
           << "\\font_sf_scale " << h_font_sf_scale << "\n"
@@ -1462,7 +1468,7 @@ void Preamble::parse(Parser & p, string const & forceclass,
                                h_preamble << ss.str();
                        }
                }
-               
+
                else if (t.cs() == "AtBeginDocument") {
                        string const name = p.verbatim_item();
                        // only non-lyxspecific stuff
index a0e5198d73682c659b5e21ca91d9573475ec9834..ae5886e08e854c7b92fb3b6d38f46c79c7c5e72a 100644 (file)
@@ -53,6 +53,8 @@ public:
        /// The language of text which is not explicitly marked
        std::string defaultLanguage() const  { return default_language; }
        ///
+       bool usePolyglossia() const;
+       ///
        std::string use_indices() const { return h_use_indices; }
        ///
        std::string polyglossia2lyx(std::string const & language);
@@ -130,7 +132,7 @@ private:
        std::string h_font_sans;
        std::string h_font_typewriter;
        std::string h_font_default_family;
-       std::string h_use_non_tex_fonts;
+       bool h_use_non_tex_fonts;
        std::string h_font_sc;
        std::string h_font_osf;
        std::string h_font_sf_scale;
index 5b41fab521207ef0a76dd84d27e698c758aee7fc..40a250a5a65525b520f891df9416f9041859df18 100644 (file)
@@ -2121,9 +2121,37 @@ from textcomp: №™
 
 \size normal
 from textgreek and textcyr: 
-\lang greek
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+
+\backslash
+textgreek
+\end_layout
+
+\end_inset
+
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+{
+\end_layout
+
+\end_inset
+
 >a
-\lang english
+\begin_inset ERT
+status collapsed
+
+\begin_layout Plain Layout
+}
+\end_layout
+
+\end_inset
+
 в
 \end_layout
 
index c899fb2c4ee7d7d7fd74bf7470cb6a9af7855095..f1537df41135f9de9f31db60a7688dd5813080d3 100644 (file)
@@ -3746,7 +3746,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                                              context.font.language, lang);
                }
 
-               else if (prefixIs(t.cs(), "text")
+               else if (prefixIs(t.cs(), "text") && preamble.usePolyglossia()
                         && is_known(t.cs().substr(4), preamble.polyglossia_languages)) {
                        // scheme is \textLANGUAGE{text} where LANGUAGE is in polyglossia_languages[]
                        string lang;