static private Ligature ( char newchar, Charstruct oldchar ) : int | ||
newchar | char | |
oldchar | Charstruct | |
return | int |
static int Ligature(char newchar, Charstruct oldchar)
{
/* 0 == no ligature possible; 1 == vowel; 2 == two chars; 3 == Lam+Alef */
int retval = 0;
if (oldchar.basechar == 0)
return 0;
if (IsVowel(newchar)) {
retval = 1;
if ((oldchar.vowel != 0) && (newchar != SHADDA)) {
retval = 2; /* we eliminate the old vowel .. */
}
switch (newchar) {
case SHADDA:
if (oldchar.mark1 == 0) {
oldchar.mark1 = SHADDA;
}
else {
return 0; /* no ligature possible */
}
break;
case HAMZABELOW:
switch (oldchar.basechar) {
case ALEF:
oldchar.basechar = ALEFHAMZABELOW;
retval = 2;
break;
case LAM_ALEF:
oldchar.basechar = LAM_ALEFHAMZABELOW;
retval = 2;
break;
default:
oldchar.mark1 = HAMZABELOW;
break;
}
break;
case HAMZAABOVE:
switch (oldchar.basechar) {
case ALEF:
oldchar.basechar = ALEFHAMZA;
retval = 2;
break;
case LAM_ALEF:
oldchar.basechar = LAM_ALEFHAMZA;
retval = 2;
break;
case WAW:
oldchar.basechar = WAWHAMZA;
retval = 2;
break;
case YEH:
case ALEFMAKSURA:
case FARSIYEH:
oldchar.basechar = YEHHAMZA;
retval = 2;
break;
default: /* whatever sense this may make .. */
oldchar.mark1 = HAMZAABOVE;
break;
}
break;
case MADDA:
switch (oldchar.basechar) {
case ALEF:
oldchar.basechar = ALEFMADDA;
retval = 2;
break;
}
break;
default:
oldchar.vowel = newchar;
break;
}
if (retval == 1) {
oldchar.lignum++;
}
return retval;
}
if (oldchar.vowel != 0) { /* if we already joined a vowel, we can't join a Hamza */
return 0;
}
switch (oldchar.basechar) {
case LAM:
switch (newchar) {
case ALEF:
oldchar.basechar = LAM_ALEF;
oldchar.numshapes = 2;
retval = 3;
break;
case ALEFHAMZA:
oldchar.basechar = LAM_ALEFHAMZA;
oldchar.numshapes = 2;
retval = 3;
break;
case ALEFHAMZABELOW:
oldchar.basechar = LAM_ALEFHAMZABELOW;
oldchar.numshapes = 2;
retval = 3;
break;
case ALEFMADDA:
oldchar.basechar = LAM_ALEFMADDA;
oldchar.numshapes = 2;
retval = 3;
break;
}
break;
case (char)0:
oldchar.basechar = newchar;
oldchar.numshapes = Shapecount(newchar);
retval = 1;
break;
}
return retval;
}