src/3rdparty/harfbuzz/src/harfbuzz-indic.cpp
changeset 22 79de32ba3296
parent 3 41300fa6a67c
equal deleted inserted replaced
19:fcece45ef507 22:79de32ba3296
  1105     len += added_chars;
  1105     len += added_chars;
  1106 }
  1106 }
  1107 
  1107 
  1108 #ifndef NO_OPENTYPE
  1108 #ifndef NO_OPENTYPE
  1109 static const HB_OpenTypeFeature indic_features[] = {
  1109 static const HB_OpenTypeFeature indic_features[] = {
       
  1110     { HB_MAKE_TAG('l', 'o', 'c', 'a'), LocaProperty },
  1110     { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },
  1111     { HB_MAKE_TAG('c', 'c', 'm', 'p'), CcmpProperty },
  1111     { HB_MAKE_TAG('i', 'n', 'i', 't'), InitProperty },
  1112     { HB_MAKE_TAG('i', 'n', 'i', 't'), InitProperty },
  1112     { HB_MAKE_TAG('n', 'u', 'k', 't'), NuktaProperty },
  1113     { HB_MAKE_TAG('n', 'u', 'k', 't'), NuktaProperty },
  1113     { HB_MAKE_TAG('a', 'k', 'h', 'n'), AkhantProperty },
  1114     { HB_MAKE_TAG('a', 'k', 'h', 'n'), AkhantProperty },
  1114     { HB_MAKE_TAG('r', 'p', 'h', 'f'), RephProperty },
  1115     { HB_MAKE_TAG('r', 'p', 'h', 'f'), RephProperty },
  1115     { HB_MAKE_TAG('b', 'l', 'w', 'f'), BelowFormProperty },
  1116     { HB_MAKE_TAG('b', 'l', 'w', 'f'), BelowFormProperty },
  1116     { HB_MAKE_TAG('h', 'a', 'l', 'f'), HalfFormProperty },
  1117     { HB_MAKE_TAG('h', 'a', 'l', 'f'), HalfFormProperty },
  1117     { HB_MAKE_TAG('p', 's', 't', 'f'), PostFormProperty },
  1118     { HB_MAKE_TAG('p', 's', 't', 'f'), PostFormProperty },
       
  1119     { HB_MAKE_TAG('c', 'j', 'c', 't'), ConjunctFormProperty },
  1118     { HB_MAKE_TAG('v', 'a', 't', 'u'), VattuProperty },
  1120     { HB_MAKE_TAG('v', 'a', 't', 'u'), VattuProperty },
  1119     { HB_MAKE_TAG('p', 'r', 'e', 's'), PreSubstProperty },
  1121     { HB_MAKE_TAG('p', 'r', 'e', 's'), PreSubstProperty },
  1120     { HB_MAKE_TAG('b', 'l', 'w', 's'), BelowSubstProperty },
  1122     { HB_MAKE_TAG('b', 'l', 'w', 's'), BelowSubstProperty },
  1121     { HB_MAKE_TAG('a', 'b', 'v', 's'), AboveSubstProperty },
  1123     { HB_MAKE_TAG('a', 'b', 'v', 's'), AboveSubstProperty },
  1122     { HB_MAKE_TAG('p', 's', 't', 's'), PostSubstProperty },
  1124     { HB_MAKE_TAG('p', 's', 't', 's'), PostSubstProperty },
  1123     { HB_MAKE_TAG('h', 'a', 'l', 'n'), HalantProperty },
  1125     { HB_MAKE_TAG('h', 'a', 'l', 'n'), HalantProperty },
       
  1126     { HB_MAKE_TAG('c', 'a', 'l', 't'), IndicCaltProperty },
  1124     { 0, 0 }
  1127     { 0, 0 }
  1125 };
  1128 };
  1126 #endif
  1129 #endif
  1127 
  1130 
  1128 // #define INDIC_DEBUG
  1131 // #define INDIC_DEBUG
  1146 #if 0 //def INDIC_DEBUG
  1149 #if 0 //def INDIC_DEBUG
  1147 static QString propertiesToString(int properties)
  1150 static QString propertiesToString(int properties)
  1148 {
  1151 {
  1149     QString res;
  1152     QString res;
  1150     properties = ~properties;
  1153     properties = ~properties;
       
  1154     if (properties & LocaProperty)
       
  1155         res += "Loca ";
  1151     if (properties & CcmpProperty)
  1156     if (properties & CcmpProperty)
  1152         res += "Ccmp ";
  1157         res += "Ccmp ";
  1153     if (properties & InitProperty)
  1158     if (properties & InitProperty)
  1154         res += "Init ";
  1159         res += "Init ";
  1155     if (properties & NuktaProperty)
  1160     if (properties & NuktaProperty)
  1166         res += "AboveForm ";
  1171         res += "AboveForm ";
  1167     if (properties & HalfFormProperty)
  1172     if (properties & HalfFormProperty)
  1168         res += "HalfForm ";
  1173         res += "HalfForm ";
  1169     if (properties & PostFormProperty)
  1174     if (properties & PostFormProperty)
  1170         res += "PostForm ";
  1175         res += "PostForm ";
       
  1176     if (properties & ConjunctFormProperty)
       
  1177         res += "PostForm ";
  1171     if (properties & VattuProperty)
  1178     if (properties & VattuProperty)
  1172         res += "Vattu ";
  1179         res += "Vattu ";
  1173     if (properties & PreSubstProperty)
  1180     if (properties & PreSubstProperty)
  1174         res += "PreSubst ";
  1181         res += "PreSubst ";
  1175     if (properties & BelowSubstProperty)
  1182     if (properties & BelowSubstProperty)
  1180         res += "PostSubst ";
  1187         res += "PostSubst ";
  1181     if (properties & HalantProperty)
  1188     if (properties & HalantProperty)
  1182         res += "Halant ";
  1189         res += "Halant ";
  1183     if (properties & CligProperty)
  1190     if (properties & CligProperty)
  1184         res += "Clig ";
  1191         res += "Clig ";
       
  1192     if (properties & IndicCaltProperty)
       
  1193         res += "Calt ";
  1185     return res;
  1194     return res;
  1186 }
  1195 }
  1187 #endif
  1196 #endif
  1188 
  1197 
  1189 static bool indic_shape_syllable(HB_Bool openType, HB_ShaperItem *item, bool invalid)
  1198 static bool indic_shape_syllable(HB_Bool openType, HB_ShaperItem *item, bool invalid)
  1294                         matra = i;
  1303                         matra = i;
  1295                 }
  1304                 }
  1296             }
  1305             }
  1297             int skipped = 0;
  1306             int skipped = 0;
  1298             Position pos = Post;
  1307             Position pos = Post;
  1299             for (i = len-1; i > base; i--) {
  1308             for (i = len-1; i >= base; i--) {
  1300                 if (position[i] != Consonant && (position[i] != Control || script == HB_Script_Kannada))
  1309                 if (position[i] != Consonant && (position[i] != Control || script == HB_Script_Kannada))
  1301                     continue;
  1310                     continue;
       
  1311 
       
  1312                 if (i < len-1 && position[i] == Control && position[i+1] == Consonant) {
       
  1313                     base = i+1;
       
  1314                     break;
       
  1315                 }
  1302 
  1316 
  1303                 Position charPosition = indic_position(uc[i]);
  1317                 Position charPosition = indic_position(uc[i]);
  1304                 if (pos == Post && charPosition == Post) {
  1318                 if (pos == Post && charPosition == Post) {
  1305                     pos = Post;
  1319                     pos = Post;
  1306                 } else if ((pos == Post || pos == Below) && charPosition == Below) {
  1320                 } else if ((pos == Post || pos == Below) && charPosition == Below) {
  1543         for (i = 0; i < len; ++i)
  1557         for (i = 0; i < len; ++i)
  1544             clusters[i] = i;
  1558             clusters[i] = i;
  1545 
  1559 
  1546         // features we should always apply
  1560         // features we should always apply
  1547         for (i = 0; i < len; ++i)
  1561         for (i = 0; i < len; ++i)
  1548             properties[i] = ~(CcmpProperty
  1562             properties[i] = ~(LocaProperty
       
  1563                               | CcmpProperty
  1549                               | NuktaProperty
  1564                               | NuktaProperty
  1550                               | VattuProperty
  1565                               | VattuProperty
       
  1566                               | ConjunctFormProperty
  1551                               | PreSubstProperty
  1567                               | PreSubstProperty
  1552                               | BelowSubstProperty
  1568                               | BelowSubstProperty
  1553                               | AboveSubstProperty
  1569                               | AboveSubstProperty
  1554                               | PostSubstProperty
  1570                               | PostSubstProperty
  1555                               | HalantProperty
  1571                               | HalantProperty
       
  1572                               | IndicCaltProperty
  1556                               | PositioningProperties);
  1573                               | PositioningProperties);
  1557 
  1574 
       
  1575         // Loca always applies
  1558         // Ccmp always applies
  1576         // Ccmp always applies
  1559         // Init
  1577         // Init
  1560         if (item->item.pos == 0
  1578         if (item->item.pos == 0
  1561             || !(isLetter(item->string[item->item.pos-1]) || isMark(item->string[item->item.pos-1])))
  1579             || !(isLetter(item->string[item->item.pos-1]) || isMark(item->string[item->item.pos-1])))
  1562             properties[0] &= ~InitProperty;
  1580             properties[0] &= ~InitProperty;
  1609         // pres always applies
  1627         // pres always applies
  1610         // blws always applies
  1628         // blws always applies
  1611         // abvs always applies
  1629         // abvs always applies
  1612         // psts always applies
  1630         // psts always applies
  1613         // halant always applies
  1631         // halant always applies
       
  1632         // calt always applies
  1614 
  1633 
  1615 #ifdef INDIC_DEBUG
  1634 #ifdef INDIC_DEBUG
  1616 //        {
  1635 //        {
  1617 //            IDEBUG("OT properties:");
  1636 //            IDEBUG("OT properties:");
  1618 //            for (int i = 0; i < len; ++i)
  1637 //            for (int i = 0; i < len; ++i)