]> git.lyx.org Git - features.git/commitdiff
Fix misparsing of \textgreek without polyglossia
authorGeorg Baum <baum@lyx.org>
Sat, 3 Jan 2015 16:27:22 +0000 (17:27 +0100)
committerGeorg Baum <baum@lyx.org>
Sat, 3 Jan 2015 16:27:22 +0000 (17:27 +0100)
\textgreek was interpreted as the polyglossia version even if polyglossia
was not used. Now the symbols defined in unicodesymbols are detected correctly
and converted to unicode, while others are converted to ERT (bug #8553).

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

index 7cf11bcefb0ef151c125b16d8fb547b07ed25a48..65d978fa89c115ef7c57f4c5eeebddcde8320331 100644 (file)
@@ -303,7 +303,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",
@@ -329,6 +329,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";
@@ -461,7 +467,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";
@@ -659,7 +665,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");
@@ -701,7 +707,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";
@@ -846,7 +852,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")
@@ -1124,7 +1130,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"
@@ -1459,7 +1465,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 3216c3cc6d697edab7c766bed8a293903af427cb..91f3a4882f969896bf5607de1d871f646b7abbdc 100644 (file)
@@ -51,6 +51,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);
@@ -128,7 +130,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 5645b5b9c535e4f56a254179b7af858e2112707b..74ee1a40f4702277614ba145f6c020f04e35dc75 100644 (file)
@@ -2120,11 +2120,7 @@ from textcomp: №™
 \begin_layout Standard
 
 \size normal
-from textgreek and textcyr: 
-\lang greek
->a
-\lang english
+from textgreek and textcyr: ἀв
 \end_layout
 
 \begin_layout Standard
index 5657d95b61fccbd8c781ed4c71d80581734e59e2..9152360cfb18a1ce83de83ce324863bfde82ea0f 100644 (file)
@@ -3823,7 +3823,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;
@@ -4622,8 +4622,9 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        // Only use text mode commands, since we are in text mode here,
                        // and math commands may be invalid (bug 6797)
                        string name = t.asInput();
-                       // handle the dingbats and Cyrillic
-                       if (name == "\\ding" || name == "\\textcyr")
+                       // handle the dingbats, cyrillic and greek
+                       if (name == "\\ding" || name == "\\textcyr" ||
+                           (name == "\\textgreek" && !preamble.usePolyglossia()))
                                name = name + '{' + p.getArg('{', '}') + '}';
                        // handle the ifsym characters
                        else if (name == "\\textifsymbol") {
index b7ff3f389872d090ea9e8fea1663b2d3feb0a8d0..fc2fc48664a2abaf65821cffdc9cd4cae6b1f674 100644 (file)
@@ -186,6 +186,8 @@ What's new
 
 - Parse tikzpicture environment correctly (bug 9011).
 
+- Fix misparsing of \textgreek without polyglossia (bug 8553).
+
 
 
 * ADVANCED FIND AND REPLACE