OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 2 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
3 * | 3 * |
4 * This is part of HarfBuzz, an OpenType Layout engine library. | 4 * This is part of HarfBuzz, an OpenType Layout engine library. |
5 * | 5 * |
6 * Permission is hereby granted, without written agreement and without | 6 * Permission is hereby granted, without written agreement and without |
7 * license or royalty fees, to use, copy, modify, and distribute this | 7 * license or royalty fees, to use, copy, modify, and distribute this |
8 * software and its documentation for any purpose, provided that the | 8 * software and its documentation for any purpose, provided that the |
9 * above copyright notice and the following two paragraphs appear in | 9 * above copyright notice and the following two paragraphs appear in |
10 * all copies of this software. | 10 * all copies of this software. |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 memmove(reordered + matra + added_chars, reordered + matra, (len-matra)*size
of(unsigned short)); | 1100 memmove(reordered + matra + added_chars, reordered + matra, (len-matra)*size
of(unsigned short)); |
1101 reordered[matra] = split[0]; | 1101 reordered[matra] = split[0]; |
1102 reordered[matra+1] = split[1]; | 1102 reordered[matra+1] = split[1]; |
1103 if(added_chars == 2) | 1103 if(added_chars == 2) |
1104 reordered[matra+2] = split[2]; | 1104 reordered[matra+2] = split[2]; |
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 |
1129 #ifdef INDIC_DEBUG | 1132 #ifdef INDIC_DEBUG |
1130 #define IDEBUG hb_debug | 1133 #define IDEBUG hb_debug |
1131 #include <stdarg.h> | 1134 #include <stdarg.h> |
1132 | 1135 |
1133 static void hb_debug(const char *msg, ...) | 1136 static void hb_debug(const char *msg, ...) |
1134 { | 1137 { |
1135 va_list ap; | 1138 va_list ap; |
1136 va_start(ap, msg); // use variable arg list | 1139 va_start(ap, msg); // use variable arg list |
1137 vfprintf(stderr, msg, ap); | 1140 vfprintf(stderr, msg, ap); |
1138 va_end(ap); | 1141 va_end(ap); |
1139 fprintf(stderr, "\n"); | 1142 fprintf(stderr, "\n"); |
1140 } | 1143 } |
1141 | 1144 |
1142 #else | 1145 #else |
1143 #define IDEBUG if(0) printf | 1146 #define IDEBUG if(0) printf |
1144 #endif | 1147 #endif |
1145 | 1148 |
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) |
1156 res += "Nukta "; | 1161 res += "Nukta "; |
1157 if (properties & AkhantProperty) | 1162 if (properties & AkhantProperty) |
1158 res += "Akhant "; | 1163 res += "Akhant "; |
1159 if (properties & RephProperty) | 1164 if (properties & RephProperty) |
1160 res += "Reph "; | 1165 res += "Reph "; |
1161 if (properties & PreFormProperty) | 1166 if (properties & PreFormProperty) |
1162 res += "PreForm "; | 1167 res += "PreForm "; |
1163 if (properties & BelowFormProperty) | 1168 if (properties & BelowFormProperty) |
1164 res += "BelowForm "; | 1169 res += "BelowForm "; |
1165 if (properties & AboveFormProperty) | 1170 if (properties & AboveFormProperty) |
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) |
1176 res += "BelowSubst "; | 1183 res += "BelowSubst "; |
1177 if (properties & AboveSubstProperty) | 1184 if (properties & AboveSubstProperty) |
1178 res += "AboveSubst "; | 1185 res += "AboveSubst "; |
1179 if (properties & PostSubstProperty) | 1186 if (properties & PostSubstProperty) |
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 inv
alid) | 1198 static bool indic_shape_syllable(HB_Bool openType, HB_ShaperItem *item, bool inv
alid) |
1190 { | 1199 { |
1191 HB_Script script = item->item.script; | 1200 HB_Script script = item->item.script; |
1192 assert(script >= HB_Script_Devanagari && script <= HB_Script_Sinhala); | 1201 assert(script >= HB_Script_Devanagari && script <= HB_Script_Sinhala); |
1193 const unsigned short script_base = 0x0900 + 0x80*(script-HB_Script_Devanagar
i); | 1202 const unsigned short script_base = 0x0900 + 0x80*(script-HB_Script_Devanagar
i); |
1194 const unsigned short ra = script_base + 0x30; | 1203 const unsigned short ra = script_base + 0x30; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 for (i = base; i < len; ++i) { | 1298 for (i = base; i < len; ++i) { |
1290 position[i] = form(uc[i]); | 1299 position[i] = form(uc[i]); |
1291 if (position[i] == Consonant) | 1300 if (position[i] == Consonant) |
1292 lastConsonant = i; | 1301 lastConsonant = i; |
1293 else if (matra < 0 && position[i] == Matra) | 1302 else if (matra < 0 && position[i] == Matra) |
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 || scrip
t == HB_Script_Kannada)) | 1309 if (position[i] != Consonant && (position[i] != Control || scrip
t == HB_Script_Kannada)) |
1301 continue; | 1310 continue; |
1302 | 1311 |
| 1312 if (i < len-1 && position[i] == Control && position[i+1] == Cons
onant) { |
| 1313 base = i+1; |
| 1314 break; |
| 1315 } |
| 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 == Belo
w) { | 1320 } else if ((pos == Post || pos == Below) && charPosition == Belo
w) { |
1307 if (script == HB_Script_Devanagari || script == HB_Script_Gu
jarati) | 1321 if (script == HB_Script_Devanagari || script == HB_Script_Gu
jarati) |
1308 base = i; | 1322 base = i; |
1309 pos = Below; | 1323 pos = Below; |
1310 } else { | 1324 } else { |
1311 base = i; | 1325 base = i; |
1312 break; | 1326 break; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1538 // is rather simple, as all chars just point to the first | 1552 // is rather simple, as all chars just point to the first |
1539 // glyph in the syllable. | 1553 // glyph in the syllable. |
1540 HB_STACKARRAY(unsigned short, clusters, len); | 1554 HB_STACKARRAY(unsigned short, clusters, len); |
1541 HB_STACKARRAY(unsigned int, properties, len); | 1555 HB_STACKARRAY(unsigned int, properties, len); |
1542 | 1556 |
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; |
1563 | 1581 |
1564 // Nukta always applies | 1582 // Nukta always applies |
1565 // Akhant | 1583 // Akhant |
1566 for (i = 0; i <= base; ++i) | 1584 for (i = 0; i <= base; ++i) |
1567 properties[i] &= ~AkhantProperty; | 1585 properties[i] &= ~AkhantProperty; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 } | 1622 } |
1605 // PostFormProperty | 1623 // PostFormProperty |
1606 for (i = base+1; i < len; ++i) | 1624 for (i = base+1; i < len; ++i) |
1607 properties[i] &= ~PostFormProperty; | 1625 properties[i] &= ~PostFormProperty; |
1608 // vattu always applies | 1626 // vattu always applies |
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) |
1619 // qDebug(" i: %s", ::propertiesToString(properties[i]).toLati
n1().data()); | 1638 // qDebug(" i: %s", ::propertiesToString(properties[i]).toLati
n1().data()); |
1620 // } | 1639 // } |
1621 #endif | 1640 #endif |
1622 | 1641 |
1623 // initialize | 1642 // initialize |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1864 ++uc; | 1883 ++uc; |
1865 ++i; | 1884 ++i; |
1866 } | 1885 } |
1867 assert(i == boundary); | 1886 assert(i == boundary); |
1868 } | 1887 } |
1869 | 1888 |
1870 | 1889 |
1871 } | 1890 } |
1872 | 1891 |
1873 | 1892 |
OLD | NEW |