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).
This commit is contained in:
Georg Baum 2015-01-03 17:27:22 +01:00
parent 202e848a0e
commit 8b75ce5830
5 changed files with 23 additions and 16 deletions

View 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

View 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;

View 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

View 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") {

View 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