Attached is a better patch where everything is implemented:
- correct encoding for the fontenc package. Mostafa tested this and gave his OK
for this issue.
- special quotation mark definitions for Farsi. Mostafa tested this and gave
his OK for this issue.
- fix for bug 2929 - use \textAR and not \R. Improved version of Dov's patch.
Mostafa also tested
this successfully.
- use the document language also for the TOC. This is a special arabi-package
thing. Please test.
- To make the TOC settings work and also for other issues, arabic must be
loaded to babel too when
farsi is the document language. Please test.
Mostafa, when you give your OK I'll commit it. When there are possible problems with the two new
things, I'll only commit the uncritical and tested issues from above.
(With this patch now also your example_lyxified.lyx you sent two days ago to be added to LyX's
examples compiles for me.)
Dov, OK by you?
I think we have now a clean setup for boths languages based on the arabi
package.
José, can this go in? I think it's worth because without this patch Arabic is not usable and for
Farsi only with preamble hacks.
regards Uwe
Index: lib/languages
===================================================================
--- lib/languages (revision 18849)
+++ lib/languages (working copy)
@@ -25,7 +25,8 @@
# Esperanto has no country code
esperanto esperanto "Esperanto" false iso8859-3 eo ""
estonian estonian "Estonian" false iso8859-15 et_EE ""
-farsi farsi "Farsi" true utf8 fa_IR ""
+# the definitions are only used due to bugs in the arabi-package - remove them if they become unnecessary!
+farsi farsi "Farsi" true utf8 fa_IR "[EMAIL PROTECTED]@R{#1}}}\DeclareTextSymbol{\guillemotright}{LFE}{62}\DeclareTextSymbol{\guillemotleft}{LFE}{60}"
finnish finnish "Finnish" false iso8859-15 fi_FI ""
# We redefine \og and \fg (guillemets) for older french language definitions
french french "French" false iso8859-15 fr_FR "\addto\extrasfrench{\providecommand{\og}{\leavevmode\flqq~}\providecommand{\fg}{\ifdim\lastskip>[EMAIL PROTECTED]"
Index: src/BufferParams.cpp
===================================================================
--- src/BufferParams.cpp (revision 18849)
+++ src/BufferParams.cpp (working copy)
@@ -855,6 +855,13 @@
bool const use_babel = features.useBabel();
if (use_babel) {
language_options << features.getLanguages();
+ // arabic must also be loaded when farsi is the document language
+ // this is hopefully not needed with future versions of the arabi-package
+ if (language->lang() == "farsi") {
+ if (!features.getLanguages().empty())
+ language_options << ',';
+ language_options << "arabic";
+ }
if (!language->babel().empty()) {
if (!language_options.str().empty())
language_options << ',';
@@ -892,9 +899,17 @@
if (fontsDefaultFamily != "default")
os << "\\renewcommand{\\familydefault}{\\"
<< from_ascii(fontsDefaultFamily) << "}\n";
+
+ // set font encoding
// this one is not per buffer
- if (lyxrc.fontenc != "default") {
+ // for Arabic and Farsi we also need to load the LAE and LFE encoding
+ if ((lyxrc.fontenc != "default" && language->lang() == "arabic") ||
+ (lyxrc.fontenc != "default" && language->lang() == "farsi")) {
os << "\\usepackage[" << from_ascii(lyxrc.fontenc)
+ << ",LFE,LAE]{fontenc}\n";
+ texrow.newline();
+ } else {
+ os << "\\usepackage[" << from_ascii(lyxrc.fontenc)
<< "]{fontenc}\n";
texrow.newline();
}
@@ -1144,8 +1159,16 @@
lyxpreamble += from_utf8(features.getBabelOptions());
}
- lyxpreamble += "\\makeatother\n";
+ // these definitions are needed by the arabi-package
+ // when the document language is Arabic or Farsi, the language is set
+ // as the language for the TOC
+ if (language->babel() == "arabic")
+ lyxpreamble += "\\TOCLanguage{arabic}\n";
+ if (language->babel() == "farsi")
+ lyxpreamble += "\\TOCLanguage{farsi}\n";
+ lyxpreamble += "\\makeatother\n\n";
+
int const nlines =
int(lyx::count(lyxpreamble.begin(), lyxpreamble.end(), '\n'));
for (int j = 0; j != nlines; ++j) {
Index: src/Font.cpp
===================================================================
--- src/Font.cpp (revision 18849)
+++ src/Font.cpp (working copy)
@@ -756,6 +756,13 @@
base.language()->lang() == "farsi") {
os << "\\textLR{";
count += 8;
+ } else if (language()->lang() == "arabic") {
+ os << "\\textAR{";
+ count += 8;
+ } else if (!isRightToLeft() &&
+ base.language()->lang() == "arabic") {
+ os << "\\textLR{";
+ count += 8;
} else if (isRightToLeft() != prev.isRightToLeft()) {
if (isRightToLeft()) {
os << "\\R{";
Index: src/insets/InsetTabular.cpp
===================================================================
--- src/insets/InsetTabular.cpp (revision 18849)
+++ src/insets/InsetTabular.cpp (working copy)
@@ -2286,6 +2286,8 @@
if (par.getParLanguage(buf.params())->lang() ==
"farsi")
os << "\\textFR{";
+ else if (par.getParLanguage(buf.params())->lang() == "arabic")
+ os << "\\textAR{";
else
os << "\\R{";
}