Attached is a patch that fixes bug 8590
http://www.lyx.org/trac/ticket/8590

Currently Cyrillic Serbian documents are uncompilable which is a regression to 
LyX 2.0.5.
This bug was uncovered by commit 25e4bf4b2 by Enrico which correctly loads the T2A font encoding. The problem is that Cyrillic Serbian (and only that language) requires "T2A" as last option for fontenc.

I tested the patch with many language combinations and it works so far. But I would like to hear from anybody who is familiar with Cyrillic or Greek and/or the font encoding business. Jürgen Milde, Enrico?

(Currently we also have a bug when mixing Serbian and Serbian (Latin) but this 
another issue.)

thanks and regards
Uwe
diff --git "a/C:\\DOCUME~1\\usti\\LOCALS~1\\Temp\\TortoiseGit\\Buf2F.tmp\\BufferParams-6633a93-left.cpp" "b/D:\\LyXGit\\Master\\src\\BufferParams.cpp"
index b5aafa8..d5e83a5 100644
--- "a/C:\\DOCUME~1\\usti\\LOCALS~1\\Temp\\TortoiseGit\\Buf2F.tmp\\BufferParams-6633a93-left.cpp"
+++ "b/D:\\LyXGit\\Master\\src\\BufferParams.cpp"
@@ -1457,6 +1457,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
 	// set font encoding
 	// for arabic_arabi and farsi we also need to load the LAE and
 	// LFE encoding
+	// if Cyrillic Serbian is used "T2A" must be set as last option for fontenc
 	// XeTeX and LuaTeX (with OS fonts) work without fontenc
 	if (font_encoding() != "default" && language->lang() != "japanese"
 	    && !useNonTeXFonts && !features.isProvided("fontenc")) {
@@ -1470,18 +1471,44 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
 		}
 		if (!extra_encoding.empty() && !font_encoding().empty())
 			extra_encoding.push_back(',');
+
+		// check if "serbian" but not "serbian-latin" is used
+		// First create a list with all the input encodings used in the document
+		set<string> encodings =
+			features.getEncodingSet(language->encoding()->latexName());
+		int isSerbianCyrillic = 0;
+		// only Cyrillic Serbian is of interest, therefore check for the encoding
+		set<string>::const_iterator it = encodings.begin();
+		set<string>::const_iterator const end = encodings.end();
+		for (; it != end; ++it) {
+			if (from_ascii(*it) == "iso88595")
+				isSerbianCyrillic = 1;
+		}
+		if ((language->lang() == "serbian"
+			 || language_options.str().find("serbian") != string::npos)
+			&& (isSerbianCyrillic == 1
+			    || language->encoding()->latexName() == "iso88595"))
+			isSerbianCyrillic = 2;
+
 		size_t fars = language_options.str().find("farsi");
 		size_t arab = language_options.str().find("arabic");
 		if (language->lang() == "arabic_arabi"
 			|| language->lang() == "farsi" || fars != string::npos
 			|| arab != string::npos) {
 			os << "\\usepackage[" << extra_encoding
-			   << from_ascii(font_encoding())
-			   << ",LFE,LAE]{fontenc}\n";
+			   << from_ascii(font_encoding());
+			// for Serbian "T2A" must be the last fontenc option
+			if (isSerbianCyrillic== 2 && from_ascii(font_encoding()) != "T2A")
+				os << ",T2A";
+			os << ",LFE,LAE]{fontenc}\n";
 		} else {
-			os << "\\usepackage[" << extra_encoding
-			   << from_ascii(font_encoding())
-			   << "]{fontenc}\n";
+			os << "\\usepackage["
+			   << extra_encoding
+			   << from_ascii(font_encoding());
+			// for Serbian "T2A" must be the last fontenc option
+			if (isSerbianCyrillic== 2 && from_ascii(font_encoding()) != "T2A")
+				os << ",T2A";
+			os << "]{fontenc}\n";
 		}
 	}
 

Reply via email to