From: Georg Baum Date: Sat, 3 Jan 2015 16:27:22 +0000 (+0100) Subject: Fix misparsing of \textgreek without polyglossia X-Git-Tag: 2.1.3~41 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=8b75ce583020c00e0d5f2f6cdd5c8e15b3d95af4;p=features.git Fix misparsing of \textgreek without polyglossia \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). --- diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index 7cf11bcefb..65d978fa89 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -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 diff --git a/src/tex2lyx/Preamble.h b/src/tex2lyx/Preamble.h index 3216c3cc6d..91f3a4882f 100644 --- a/src/tex2lyx/Preamble.h +++ b/src/tex2lyx/Preamble.h @@ -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; diff --git a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx index 5645b5b9c5..74ee1a40f4 100644 --- a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx +++ b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx @@ -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 diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 5657d95b61..9152360cfb 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -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") { diff --git a/status.21x b/status.21x index b7ff3f3898..fc2fc48664 100644 --- a/status.21x +++ b/status.21x @@ -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