Any thoughts on this? Attached a newer version of the patch, the only
difference is incrementing the format number by one, after Jurgen's
format change.
Dov Feldstern wrote:
Uwe Stöhr wrote:
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.
Thanks for taking care of the lyx2lyx stuff! I added the requisite
comment to the FORMAT file --- could you just check your name (I'm not
sure my accents are correct) and email?
Regarding your change for the arabtex preamble --- I don't think this
code will ever be used, because one of the specific instructions for
using ArabTeX is to *never* switch the document language to "Arabic
(ArabTeX)". It doesn't work if you do that. The document language should
always be English (or whatever your primary language is, but *not*
Arabic (ArabTeX) ). The preamble stuff currently gets added by the
manual changes to the preferences file during the one-time setup.
So I removed this code in the attached patch. I guess once we know how
to activate it even if the language is used anywhere in the document,
then we can add it in again, and we won't need this change in the
preferences file.
---
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.
I know this is not correct, and I had originally removed it, but then
the language switch commands (added to the preferences during the
one-time setup for ArabTeX) were not taking effect. It looks like the
language switch commands are currently used only if babel is activated.
That's why I had added "arabic" to the babel column, just so that the
language switch commands would be used. I realize that this is not
strictly correct, and may even cause trouble when trying to mix with
other languages --- but that's the way it's currently done. We could
achieve this by changing the code (in Font.cpp, I think), but I'd rather
make more intrusive changes to the actual code only when we really know
what we should be doing, and at the moment I don't feel that we do.
In the attached patch I added back "arabtex" instead of "arabic" (+ a
comment explaining this), just to make it a little clearer. This seems
to work. Again, once we know what should really be done, we can fix it
in the correct way.
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?
I don't know how to do this in the code. Currently, this is not a
problem if the required commands are added to the preferences file
(during the one-time ArabTeX setup), as explained above.
thanks and regards
Uwe
Thanks for your work and comments!
Dov
Index: src/insets/InsetTabular.cpp
===================================================================
--- src/insets/InsetTabular.cpp (revision 18885)
+++ 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/Font.cpp
===================================================================
--- src/Font.cpp (revision 18885)
+++ 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/Text.cpp
===================================================================
--- src/Text.cpp (revision 18885)
+++ 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;
Index: src/rowpainter.cpp
===================================================================
--- src/rowpainter.cpp (revision 18885)
+++ 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/Buffer.cpp
===================================================================
--- src/Buffer.cpp (revision 18885)
+++ src/Buffer.cpp (working copy)
@@ -142,7 +142,7 @@
namespace {
-int const LYX_FORMAT = 275;
+int const LYX_FORMAT = 276;
} // namespace anon
Index: src/BufferParams.cpp
===================================================================
--- src/BufferParams.cpp (revision 18885)
+++ 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();
Index: lib/lyx2lyx/LyX.py
===================================================================
--- lib/lyx2lyx/LyX.py (revision 18885)
+++ 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,276), generate_minor_versions("1.5" , 0))]
+ ("1_5", range(246,277), generate_minor_versions("1.5" , 0))]
def formats_list():
Index: lib/lyx2lyx/lyx_1_5.py
===================================================================
--- lib/lyx2lyx/lyx_1_5.py (revision 18885)
+++ lib/lyx2lyx/lyx_1_5.py (working copy)
@@ -1808,6 +1808,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
#
@@ -1842,10 +1870,12 @@
[272, []],
[273, []],
[274, [normalize_font_whitespace_274]],
- [275, [convert_graphics_rotation]]
+ [275, [convert_graphics_rotation]],
+ [276, [convert_arabic]]
]
revert = [
+ [275, [revert_arabic]],
[274, [revert_graphics_rotation]],
[273, []],
[272, [revert_separator_layout]],
Index: lib/languages
===================================================================
--- lib/languages (revision 18885)
+++ 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 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: development/FORMAT
===================================================================
--- development/FORMAT (revision 18885)
+++ development/FORMAT (working copy)
@@ -1,6 +1,11 @@
LyX file-format changes
-----------------------
+2007-06-25 Uwe Stöhr <[EMAIL PROTECTED]> and Dov Feldstern <[EMAIL
PROTECTED]>
+ * format incremented to 276: switching exsting language 'arabic' to
+ 'arabic_arabtex'; this is to differentiate from the new arabic
support
+ using the arabi package.
+
2007-05-04 Jürgen Spitzmüller <[EMAIL PROTECTED]>
* format incremented to 275: add graphics params scaleBeforeRotation