mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-12 00:39:18 +00:00
Patch for arabic from Dekel
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/lyx-1_1_5@875 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c400290b51
commit
7507a19bf6
@ -1,3 +1,11 @@
|
|||||||
|
2000-07-01 Dekel Tsur <dekel@math.tau.ac.il>
|
||||||
|
|
||||||
|
* src/text.C (TransformChar): Changed to work correctly with
|
||||||
|
Arabic points.
|
||||||
|
(draw): Added support for drawing Arabic points.
|
||||||
|
(draw): Removed code for drawing underbars (this is done by
|
||||||
|
the Painter!)
|
||||||
|
|
||||||
2000-07-10 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
2000-07-10 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||||
|
|
||||||
* configure.in: use -isystem instead of -I for X headers. This
|
* configure.in: use -isystem instead of -I for X headers. This
|
||||||
|
@ -45,9 +45,9 @@ public:
|
|||||||
|
|
||||||
enum Letter_Form {
|
enum Letter_Form {
|
||||||
FORM_ISOLATED,
|
FORM_ISOLATED,
|
||||||
|
FORM_FINAL,
|
||||||
FORM_INITIAL,
|
FORM_INITIAL,
|
||||||
FORM_MEDIAL,
|
FORM_MEDIAL
|
||||||
FORM_FINAL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
|
184
src/text.C
184
src/text.C
@ -45,83 +45,105 @@ static const int LYX_PAPER_MARGIN = 20;
|
|||||||
// ale070405
|
// ale070405
|
||||||
extern int bibitemMaxWidth(Painter &, LyXFont const &);
|
extern int bibitemMaxWidth(Painter &, LyXFont const &);
|
||||||
|
|
||||||
static int iso885968x[] = {
|
unsigned char const arabic_start = 0xc1;
|
||||||
0xbc, // 0xa8 = fathatan
|
|
||||||
0xbd, // 0xa9 = dammatan
|
|
||||||
0xbe, // 0xaa = kasratan
|
|
||||||
0xdb, // 0xab = fatha
|
|
||||||
0xdc, // 0xac = damma
|
|
||||||
0xdd, // 0xad = kasra
|
|
||||||
0xde, // 0xae = shadda
|
|
||||||
0xdf, // 0xaf = sukun
|
|
||||||
|
|
||||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0xb0-0xbf
|
unsigned char arabic_table[63][2] = {
|
||||||
|
{0xc1, 0xc1}, // 0xc1 = hamza
|
||||||
|
{0xc2, 0xc2}, // 0xc2 = ligature madda on alef
|
||||||
|
{0xc3, 0xc3}, // 0xc3 = ligature hamza on alef
|
||||||
|
{0xc4, 0xc4}, // 0xc4 = ligature hamza on waw
|
||||||
|
{0xc5, 0xc5}, // 0xc5 = ligature hamza under alef
|
||||||
|
{0xc6, 0xc0}, // 0xc6 = ligature hamza on ya
|
||||||
|
{0xc7, 0xc7}, // 0xc7 = alef
|
||||||
|
{0xc8, 0xeb}, // 0xc8 = baa
|
||||||
|
{0xc9, 0xc9}, // 0xc9 = taa marbuta
|
||||||
|
{0xca, 0xec}, // 0xca = taa
|
||||||
|
{0xcb, 0xed}, // 0xcb = thaa
|
||||||
|
{0xcc, 0xee}, // 0xcc = jeem
|
||||||
|
{0xcd, 0xef}, // 0xcd = haa
|
||||||
|
{0xce, 0xf0}, // 0xce = khaa
|
||||||
|
{0xcf, 0xcf}, // 0xcf = dal
|
||||||
|
|
||||||
0, // 0xc0
|
{0xd0, 0xd0}, // 0xd0 = thal
|
||||||
0xc1, // 0xc1 = hamza
|
{0xd1, 0xd1}, // 0xd1 = ra
|
||||||
0xc2, // 0xc2 = ligature madda
|
{0xd2, 0xd2}, // 0xd2 = zain
|
||||||
0xc3, // 0xc3 = ligature hamza on alef
|
{0xd3, 0xf1}, // 0xd3 = seen
|
||||||
0xc4, // 0xc4 = ligature hamza on waw
|
{0xd4, 0xf2}, // 0xd4 = sheen
|
||||||
0xc5, // 0xc5 = ligature hamza under alef
|
{0xd5, 0xf3}, // 0xd5 = sad
|
||||||
0xc0, // 0xc6 = ligature hamza on ya
|
{0xd6, 0xf4}, // 0xd6 = dad
|
||||||
0xc7, // 0xc7 = alef
|
{0xd7, 0xd7}, // 0xd7 = tah
|
||||||
0xeb, // 0xc8 = baa
|
{0xd8, 0xd8}, // 0xd8 = zah
|
||||||
0xc9, // 0xc9 = taa marbuta
|
{0xd9, 0xf5}, // 0xd9 = ain
|
||||||
0xec, // 0xca = taa
|
{0xda, 0xf6}, // 0xda = ghain
|
||||||
0xed, // 0xcb = thaa
|
{0,0}, // 0xdb
|
||||||
0xee, // 0xcc = jeem
|
{0,0}, // 0xdc
|
||||||
0xef, // 0xcd = haa
|
{0,0}, // 0xdd
|
||||||
0xf0, // 0xce = khaa
|
{0,0}, // 0xde
|
||||||
0xcf, // 0xcf = dal
|
{0,0}, // 0xdf
|
||||||
|
|
||||||
0xd0, // 0xd0 = thal
|
{0,0}, // 0xe0
|
||||||
0xd1, // 0xd1 = ra
|
{0xe1, 0xf7}, // 0xe1 = fa
|
||||||
0xd2, // 0xd2 = zain
|
{0xe2, 0xf8}, // 0xe2 = qaf
|
||||||
0xf1, // 0xd3 = seen
|
{0xe3, 0xf9}, // 0xe3 = kaf
|
||||||
0xf2, // 0xd4 = sheen
|
{0xe4, 0xfa}, // 0xe4 = lam
|
||||||
0xf3, // 0xd5 = sad
|
{0xe5, 0xfb}, // 0xe5 = meem
|
||||||
0xf4, // 0xd6 = dad
|
{0xe6, 0xfc}, // 0xe6 = noon
|
||||||
0xd7, // 0xd7 = tah
|
{0xe7, 0xfd}, // 0xe7 = ha
|
||||||
0xd8, // 0xd8 = zah
|
{0xe8, 0xe8}, // 0xe8 = waw
|
||||||
0xf5, // 0xd9 = ain
|
{0xe9, 0xe9}, // 0xe9 = alef maksura
|
||||||
0xf6, // 0xda = ghain
|
{0xea, 0xfe}, // 0xea = ya
|
||||||
0,0,0,0,0, // 0xdb- 0xdf
|
{0xa8, 0xa8}, // 0xeb = fathatan
|
||||||
|
{0xa9, 0xa9}, // 0xec = dammatan
|
||||||
|
{0xaa, 0xaa}, // 0xed = kasratan
|
||||||
|
{0xab, 0xab}, // 0xee = fatha
|
||||||
|
{0xac, 0xac}, // 0xef = damma
|
||||||
|
|
||||||
0, // 0xe0
|
{0xad, 0xad}, // 0xf0 = kasra
|
||||||
0xf7, // 0xe1 = fa
|
{0xae, 0xae}, // 0xf1 = shadda
|
||||||
0xf8, // 0xe2 = qaf
|
{0xaf, 0xaf}, // 0xf2 = sukun
|
||||||
0xf9, // 0xe3 = kaf
|
{0,0}, // 0xf3
|
||||||
0xfa, // 0xe4 = lam
|
{0,0}, // 0xf4
|
||||||
0xfb, // 0xe5 = meem
|
{0,0}, // 0xf5
|
||||||
0xfc, // 0xe6 = noon
|
{0,0}, // 0xf6
|
||||||
0xfd, // 0xe7 = ha
|
{0,0}, // 0xf7
|
||||||
0xe8, // 0xe8 = waw
|
{0,0}, // 0xf8
|
||||||
0xe9, // 0xe9 = alef maksura
|
{0,0}, // 0xf9
|
||||||
0xfe // 0xea = ya
|
{0,0}, // 0xfa
|
||||||
|
{0,0}, // 0xfb
|
||||||
|
{0,0}, // 0xfc
|
||||||
|
{0,0}, // 0xfd
|
||||||
|
{0,0}, // 0xfe
|
||||||
|
{0,0} // 0xff
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool is_arabic(unsigned char c)
|
bool is_arabic(unsigned char c)
|
||||||
{
|
{
|
||||||
return 0xa8 <= c && c <= 0xea && iso885968x[c-0xa8];
|
return c >= arabic_start && arabic_table[c-arabic_start][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool is_nikud(unsigned char c)
|
bool is_nikud(unsigned char c)
|
||||||
{
|
{
|
||||||
return 192 <= c && c <= 210;
|
return 192 <= c && c <= 210 &&
|
||||||
|
c != 0xce && c != 0xd0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline
|
||||||
|
bool IsComposeChar_arabic(unsigned char c)
|
||||||
|
{
|
||||||
|
return c >= 0xeb && c <= 0xf2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned char LyXText::TransformChar(unsigned char c, Letter_Form form) const
|
unsigned char LyXText::TransformChar(unsigned char c, Letter_Form form) const
|
||||||
{
|
{
|
||||||
if (is_arabic(c) &&
|
if (!is_arabic(c))
|
||||||
(form == FORM_INITIAL || form == FORM_MEDIAL) )
|
|
||||||
return iso885968x[c-0xa8];
|
|
||||||
else
|
|
||||||
return c;
|
return c;
|
||||||
|
else
|
||||||
|
return arabic_table[c-arabic_start][form >> 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -134,14 +156,22 @@ unsigned char LyXText::TransformChar(unsigned char c, LyXParagraph * par,
|
|||||||
else
|
else
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
bool not_first = (pos > 0 && is_arabic(par->GetChar(pos-1)));
|
|
||||||
if (pos < par->Last()-1 && is_arabic(par->GetChar(pos+1)))
|
unsigned char prev_char = pos > 0 ? par->GetChar(pos-1) : ' ';
|
||||||
if (not_first)
|
unsigned char next_char = ' ';
|
||||||
|
for (LyXParagraph::size_type i = pos+1; i < par->Last(); ++i)
|
||||||
|
if (!IsComposeChar_arabic(par->GetChar(i))) {
|
||||||
|
next_char = par->GetChar(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_arabic(next_char))
|
||||||
|
if (is_arabic(prev_char))
|
||||||
return TransformChar(c,FORM_MEDIAL);
|
return TransformChar(c,FORM_MEDIAL);
|
||||||
else
|
else
|
||||||
return TransformChar(c,FORM_INITIAL);
|
return TransformChar(c,FORM_INITIAL);
|
||||||
else
|
else
|
||||||
if (not_first)
|
if (is_arabic(prev_char))
|
||||||
return TransformChar(c,FORM_FINAL);
|
return TransformChar(c,FORM_FINAL);
|
||||||
else
|
else
|
||||||
return TransformChar(c,FORM_ISOLATED);
|
return TransformChar(c,FORM_ISOLATED);
|
||||||
@ -190,6 +220,9 @@ int LyXText::SingleWidth(LyXParagraph * par,
|
|||||||
if (font.language()->RightToLeft) {
|
if (font.language()->RightToLeft) {
|
||||||
if (font.language()->lang == "arabic" &&
|
if (font.language()->lang == "arabic" &&
|
||||||
lyxrc.font_norm == "iso8859-6.8x")
|
lyxrc.font_norm == "iso8859-6.8x")
|
||||||
|
if (IsComposeChar_arabic(c))
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
c = TransformChar(c, par, pos);
|
c = TransformChar(c, par, pos);
|
||||||
else if (font.language()->lang == "hebrew" &&
|
else if (font.language()->lang == "hebrew" &&
|
||||||
is_nikud(c))
|
is_nikud(c))
|
||||||
@ -611,18 +644,40 @@ void LyXText::draw(Row const * row,
|
|||||||
}
|
}
|
||||||
} else if (font.language()->lang == "arabic" &&
|
} else if (font.language()->lang == "arabic" &&
|
||||||
lyxrc.font_norm == "iso8859-6.8x") {
|
lyxrc.font_norm == "iso8859-6.8x") {
|
||||||
|
if (IsComposeChar_arabic(c)) {
|
||||||
|
c = TransformChar(c, row->par, pos);
|
||||||
|
textstring = c;
|
||||||
|
int width = lyxfont::width(c, font2);
|
||||||
|
int dx = 0;
|
||||||
|
for (LyXParagraph::size_type i = pos-1; i >= 0; --i) {
|
||||||
|
c = row->par->GetChar(i);
|
||||||
|
if (!IsComposeChar_arabic(c)) {
|
||||||
|
if (static_cast<unsigned char>(c) > ' ') {
|
||||||
|
int width2 = SingleWidth(row->par, i, c);
|
||||||
|
dx = (width2 - width) / 2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Draw nikud
|
||||||
|
pain.text(int(x) + dx, offset + row->baseline,
|
||||||
|
textstring, font);
|
||||||
|
} else {
|
||||||
textstring = TransformChar(c, row->par, pos);
|
textstring = TransformChar(c, row->par, pos);
|
||||||
while (vpos <= last &&
|
while (vpos <= last &&
|
||||||
(pos = vis2log(vpos)) >= 0
|
(pos = vis2log(vpos)) >= 0
|
||||||
&& static_cast<unsigned char>(c = row->par->GetChar(pos)) > ' '
|
&& static_cast<unsigned char>(c = row->par->GetChar(pos)) > ' '
|
||||||
|
&& !IsComposeChar_arabic(c)
|
||||||
&& font2 == GetFont(row->par, pos)) {
|
&& font2 == GetFont(row->par, pos)) {
|
||||||
c = TransformChar(c, row->par, pos);
|
c = TransformChar(c, row->par, pos);
|
||||||
textstring += c;
|
textstring += c;
|
||||||
++vpos;
|
++vpos;
|
||||||
}
|
}
|
||||||
// Draw text and set the new x position
|
// Draw text and set the new x position
|
||||||
pain.text(int(x), offset + row->baseline, textstring, font);
|
pain.text(int(x), offset + row->baseline,
|
||||||
|
textstring, font);
|
||||||
x += lyxfont::width(textstring, font);
|
x += lyxfont::width(textstring, font);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
while (vpos <= last &&
|
while (vpos <= last &&
|
||||||
(pos = vis2log(vpos)) >= 0
|
(pos = vis2log(vpos)) >= 0
|
||||||
@ -636,12 +691,7 @@ void LyXText::draw(Row const * row,
|
|||||||
x += lyxfont::width(textstring, font);
|
x += lyxfont::width(textstring, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
// what about underbars?
|
if (lyxrc.mark_foreign_language &&
|
||||||
if (font.underbar() == LyXFont::ON && font.latex() != LyXFont::ON) {
|
|
||||||
pain.line(int(tmpx), offset + row->baseline + 2,
|
|
||||||
int(x), offset + row->baseline + 2);
|
|
||||||
|
|
||||||
} else if (lyxrc.mark_foreign_language &&
|
|
||||||
font.language() != buffer->params.language_info) {
|
font.language() != buffer->params.language_info) {
|
||||||
int y = offset + row->height - 1;
|
int y = offset + row->height - 1;
|
||||||
pain.line(int(tmpx), y, int(x), y,
|
pain.line(int(tmpx), y, int(x), y,
|
||||||
|
Loading…
Reference in New Issue
Block a user