Attached is Dov's latest patch. I added the font encoding stuff and the fileformat change. It is
furthermore needed to load arabtex in the preamble when the language is arabic_arabtex, I added this
to the patch. Please test.
---
Dov wrote:
> +arabic_arabtex arabic "Arabic (ArabTeX)" true cp1256 ar_SA ""
When arabtex is used, babel should not be loaded (because babel is not supported by arabtex and to
avaoid interferences with arabi), I therefore corrected this line.
All other parts of your patch are OK.
I tested the last hour all combinations of languages to be save that our patch does not have any
drawbacks and I think it is save to apply.
---
There is one thing that needs to be improved: As I told you arabtex must be loaded in the preamble,
but it must be loaded whenever arabic_arabtex is used in the document, also when arabic is not the
document language. I don't know how to implement this. Currently I hae this:
if (language->lang() == "arabic_arabtex") {
os << "\\usepackage{arabtex}\n";
But this is only the document language. How can I test if one of the languages used in the document
is arabic?
thanks and regards
Uwe
Index: lib/languages
===================================================================
--- lib/languages (revision 18861)
+++ lib/languages (working copy)
@@ -1,7 +1,8 @@
# name babel name GUI name RTL? encoding code latex options
afrikaans afrikaans "Afrikaans" false iso8859-15 af_ZA ""
american american "American" false iso8859-15 en_US ""
-arabic arabic "Arabic" true cp1256 ar_SA ""
+arabic_arabtex "" "Arabic (ArabTeX)" true cp1256 ar_SA ""
+arabic_arabi arabic "Arabic (Arabi)" true cp1256 ar_SA ""
armenian "" "Armenian" false armscii8 hy_AM ""
austrian austrian "Austrian" false iso8859-15 de_AT ""
naustrian naustrian "Austrian (new spelling)" false iso8859-15 de_AT ""
Index: lib/lyx2lyx/LyX.py
===================================================================
--- lib/lyx2lyx/LyX.py (revision 18861)
+++ lib/lyx2lyx/LyX.py (working copy)
@@ -77,7 +77,7 @@
("1_2", [220], generate_minor_versions("1.2" , 4)),
("1_3", [221], generate_minor_versions("1.3" , 7)),
("1_4", range(222,246), generate_minor_versions("1.4" , 4)),
- ("1_5", range(246,275), generate_minor_versions("1.5" , 0))]
+ ("1_5", range(246,276), generate_minor_versions("1.5" , 0))]
def formats_list():
Index: lib/lyx2lyx/lyx_1_5.py
===================================================================
--- lib/lyx2lyx/lyx_1_5.py (revision 18861)
+++ lib/lyx2lyx/lyx_1_5.py (working copy)
@@ -1749,6 +1749,34 @@
r'\end_layout'
]
+def convert_arabic (document):
+ if document.language == "arabic":
+ document.language = "arabic_arabtex"
+ i = find_token(document.header, "\\language", 0)
+ if i != -1:
+ document.header[i] = "\\language arabic_arabtex"
+ i = 0
+ while i < len(document.body):
+ h = document.body[i].find("\lang arabic", 0, len(document.body[i]))
+ if (h != -1):
+ # change the language name
+ document.body[i] = '\lang arabic_arabtex'
+ i = i + 1
+
+def revert_arabic (document):
+ if document.language == "arabic_arabtex":
+ document.language = "arabic"
+ i = find_token(document.header, "\\language", 0)
+ if i != -1:
+ document.header[i] = "\\language arabic"
+ i = 0
+ while i < len(document.body):
+ h = document.body[i].find("\lang arabic_arabtex", 0, len(document.body[i]))
+ if (h != -1):
+ # change the language name
+ document.body[i] = '\lang arabic'
+ i = i + 1
+
##
# Conversion hub
#
@@ -1782,10 +1810,12 @@
[271, [convert_ext_font_sizes]],
[272, []],
[273, []],
- [274, [normalize_font_whitespace_274]]
+ [274, [normalize_font_whitespace_274]],
+ [275, [convert_arabic]]
]
revert = [
+ [274, [revert_arabic]],
[273, []],
[272, [revert_separator_layout]],
[271, [revert_preamble_listings_params, revert_listings_inset, revert_include_listings]],
Index: src/Buffer.cpp
===================================================================
--- src/Buffer.cpp (revision 18861)
+++ src/Buffer.cpp (working copy)
@@ -142,7 +142,7 @@
namespace {
-int const LYX_FORMAT = 274;
+int const LYX_FORMAT = 275;
} // namespace anon
Index: src/BufferParams.cpp
===================================================================
--- src/BufferParams.cpp (revision 18861)
+++ src/BufferParams.cpp (working copy)
@@ -895,9 +895,9 @@
// set font encoding
// this one is not per buffer
- // for Farsi we also need to load the LAE and LFE encoding
+ // for arabic_arabi and farsi we also need to load the LAE and LFE encoding
if (lyxrc.fontenc != "default") {
- if (language->lang() == "farsi") {
+ if (language->lang() == "arabic_arabi" || language->lang() == "farsi") {
os << "\\usepackage[" << from_ascii(lyxrc.fontenc)
<< ",LFE,LAE]{fontenc}\n";
texrow.newline();
@@ -1429,6 +1429,12 @@
os << "\\usepackage{armtex}\n";
texrow.newline();
}
+
+ // Load arabtex when the document language is arabic_arabtex
+ if (language->lang() == "arabic_arabtex") {
+ os << "\\usepackage{arabtex}\n";
+ texrow.newline();
+ }
}
Index: src/Font.cpp
===================================================================
--- src/Font.cpp (revision 18861)
+++ src/Font.cpp (working copy)
@@ -756,6 +756,14 @@
base.language()->lang() == "farsi") {
os << "\\textLR{";
count += 8;
+ } else if (language()->lang() == "arabic_arabi") {
+ os << "\\textAR{";
+ count += 8;
+ } else if (!isRightToLeft() &&
+ base.language()->lang() == "arabic_arabi") {
+ os << "\\textLR{";
+ count += 8;
+ // currently the remaining RTL languages are arabic_arabtex and hebrew
} else if (isRightToLeft() != prev.isRightToLeft()) {
if (isRightToLeft()) {
os << "\\R{";
Index: src/insets/InsetTabular.cpp
===================================================================
--- src/insets/InsetTabular.cpp (revision 18861)
+++ src/insets/InsetTabular.cpp (working copy)
@@ -2286,6 +2286,9 @@
if (par.getParLanguage(buf.params())->lang() ==
"farsi")
os << "\\textFR{";
+ else if (par.getParLanguage(buf.params())->lang() == "arabic_arabi")
+ os << "\\textAR{";
+ // currently, remaning RTL languages are arabic_arabtex and hebrew
else
os << "\\R{";
}
Index: src/rowpainter.cpp
===================================================================
--- src/rowpainter.cpp (revision 18861)
+++ src/rowpainter.cpp (working copy)
@@ -429,7 +429,8 @@
// special case languages
std::string const & lang = orig_font.language()->lang();
bool const hebrew = lang == "hebrew";
- bool const arabic = lang == "arabic" || lang == "farsi";
+ bool const arabic = lang == "arabic_arabtex" || lang == "arabic_arabi" ||
+ lang == "farsi";
// draw as many chars as we can
if ((!hebrew && !arabic)
Index: src/Text.cpp
===================================================================
--- src/Text.cpp (revision 18861)
+++ src/Text.cpp (working copy)
@@ -369,7 +369,8 @@
if (isPrintable(c)) {
Language const * language = font.language();
if (language->rightToLeft()) {
- if (language->lang() == "arabic" ||
+ if (language->lang() == "arabic_arabtex" ||
+ language->lang() == "arabic_arabi" ||
language->lang() == "farsi") {
if (Encodings::isComposeChar_arabic(c))
return 0;