summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/harfbuzz/src/harfbuzz-arabic.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/harfbuzz/src/harfbuzz-arabic.c')
-rw-r--r--src/3rdparty/harfbuzz/src/harfbuzz-arabic.c60
1 files changed, 57 insertions, 3 deletions
diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-arabic.c b/src/3rdparty/harfbuzz/src/harfbuzz-arabic.c
index 4d85c19277..3837087f44 100644
--- a/src/3rdparty/harfbuzz/src/harfbuzz-arabic.c
+++ b/src/3rdparty/harfbuzz/src/harfbuzz-arabic.c
@@ -489,6 +489,56 @@ static void getArabicProperties(const unsigned short *chars, int len, HB_ArabicP
*/
}
+static Joining getNkoJoining(unsigned short uc)
+{
+ if (uc < 0x7ca)
+ return JNone;
+ if (uc <= 0x7ea)
+ return JDual;
+ if (uc <= 0x7f3)
+ return JTransparent;
+ if (uc <= 0x7f9)
+ return JNone;
+ if (uc == 0x7fa)
+ return JCausing;
+ return JNone;
+}
+
+static void getNkoProperties(const unsigned short *chars, int len, HB_ArabicProperties *properties)
+{
+ int lastPos = 0;
+ int i = 0;
+
+ Joining j = getNkoJoining(chars[0]);
+ ArabicShape shape = joining_table[XIsolated][j].form2;
+ properties[0].justification = HB_NoJustification;
+
+ for (i = 1; i < len; ++i) {
+ properties[i].justification = (HB_GetUnicodeCharCategory(chars[i]) == HB_Separator_Space) ?
+ ArabicSpace : ArabicNone;
+
+ j = getNkoJoining(chars[i]);
+
+ if (j == JTransparent) {
+ properties[i].shape = XIsolated;
+ continue;
+ }
+
+ properties[lastPos].shape = joining_table[shape][j].form1;
+ shape = joining_table[shape][j].form2;
+
+
+ lastPos = i;
+ }
+ properties[lastPos].shape = joining_table[shape][JNone].form1;
+
+
+ /*
+ for (int i = 0; i < len; ++i)
+ qDebug("nko properties(%d): uc=%x shape=%d, justification=%d", i, chars[i], properties[i].shape, properties[i].justification);
+ */
+}
+
/*
// The unicode to unicode shaping codec.
// does only presentation forms B at the moment, but that should be enough for
@@ -1012,7 +1062,10 @@ static HB_Bool arabicSyriacOpenTypeShape(HB_ShaperItem *item, HB_Bool *ot_ok)
if (f + l + item->item.pos < item->stringLength) {
++l;
}
- getArabicProperties(uc+f, l, props);
+ if (item->item.script == HB_Script_Nko)
+ getNkoProperties(uc+f, l, props);
+ else
+ getArabicProperties(uc+f, l, props);
for (i = 0; i < (int)item->num_glyphs; i++) {
apply[i] = 0;
@@ -1051,7 +1104,8 @@ HB_Bool HB_ArabicShape(HB_ShaperItem *item)
HB_Bool haveGlyphs;
HB_STACKARRAY(HB_UChar16, shapedChars, item->item.length);
- assert(item->item.script == HB_Script_Arabic || item->item.script == HB_Script_Syriac);
+ assert(item->item.script == HB_Script_Arabic || item->item.script == HB_Script_Syriac
+ || item->item.script == HB_Script_Nko);
#ifndef NO_OPENTYPE
@@ -1065,7 +1119,7 @@ HB_Bool HB_ArabicShape(HB_ShaperItem *item)
}
#endif
- if (item->item.script == HB_Script_Syriac)
+ if (item->item.script != HB_Script_Arabic)
return HB_BasicShape(item);
shapedString(item->string, item->stringLength, item->item.pos, item->item.length, shapedChars, &slen,