From 7372c4abbe6abed634d71822a0f47e20e8795921 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Tue, 22 Jul 2008 11:25:15 +0000 Subject: [PATCH] Don't use the \textgreek macro when the latex encoding (iso-8859-7) is already the right one. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25797 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Paragraph.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 4a56d96697..d3e8faccb4 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -566,9 +566,10 @@ int Paragraph::Private::writeScriptChars(odocstream & os, // We only arrive here when a proper language for character text_[i] has // not been specified (i.e., it could not be translated in the current - // latex encoding) and it belongs to a known script. - // Parameter ltx contains the latex translation of text_[i] as specified in - // the unicodesymbols file and is something like "\textXXX{}". + // latex encoding) or its latex translation has been forced, and it + // belongs to a known script. + // Parameter ltx contains the latex translation of text_[i] as specified + // in the unicodesymbols file and is something like "\textXXX{}". // The latex macro name "textXXX" specifies the script to which text_[i] // belongs and we use it in order to check whether characters from the // same script immediately follow, such that we can collect them in a @@ -577,8 +578,16 @@ int Paragraph::Private::writeScriptChars(odocstream & os, docstring::size_type const brace1 = ltx.find_first_of(from_ascii("{")); docstring::size_type const brace2 = ltx.find_last_of(from_ascii("}")); string script = to_ascii(ltx.substr(1, brace1 - 1)); - int length = ltx.substr(0, brace2).length(); - os << ltx.substr(0, brace2); + int pos = 0; + int length = brace2; + bool closing_brace = true; + if (script == "textgreek" && encoding.latexName() == "iso-8859-7") { + // Correct encoding is being used, so we can avoid \textgreek. + pos = brace1 + 1; + length -= pos; + closing_brace = false; + } + os << ltx.substr(pos, length); int size = text_.size(); while (i + 1 < size) { char_type const next = text_[i + 1]; @@ -612,8 +621,10 @@ int Paragraph::Private::writeScriptChars(odocstream & os, length += len; ++i; } - os << '}'; - ++length; + if (closing_brace) { + os << '}'; + ++length; + } return length; } -- 2.39.2