summaryrefslogtreecommitdiff
path: root/Build/source/libs/icu-xetex/layout/KhmerReordering.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/icu-xetex/layout/KhmerReordering.cpp')
-rw-r--r--Build/source/libs/icu-xetex/layout/KhmerReordering.cpp192
1 files changed, 80 insertions, 112 deletions
diff --git a/Build/source/libs/icu-xetex/layout/KhmerReordering.cpp b/Build/source/libs/icu-xetex/layout/KhmerReordering.cpp
index 8d1045569a2..4f1c442a825 100644
--- a/Build/source/libs/icu-xetex/layout/KhmerReordering.cpp
+++ b/Build/source/libs/icu-xetex/layout/KhmerReordering.cpp
@@ -1,6 +1,6 @@
/*
*
- * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1998-2006 - All Rights Reserved
*
* This file is a modification of the ICU file IndicReordering.cpp
* by Jens Herden and Javier Sola for Khmer language
@@ -8,6 +8,7 @@
*/
#include "LETypes.h"
+#include "OpenTypeTables.h"
#include "KhmerReordering.h"
#include "LEGlyphStorage.h"
@@ -123,7 +124,7 @@ const KhmerClassTable *KhmerClassTable::getKhmerClassTable()
-class ReorderingOutput : public UMemory {
+class KhmerReorderingOutput : public UMemory {
private:
le_int32 fOutIndex;
LEUnicode *fOutChars;
@@ -132,25 +133,25 @@ private:
public:
- ReorderingOutput(LEUnicode *outChars, LEGlyphStorage &glyphStorage)
+ KhmerReorderingOutput(LEUnicode *outChars, LEGlyphStorage &glyphStorage)
: fOutIndex(0), fOutChars(outChars), fGlyphStorage(glyphStorage)
{
// nothing else to do...
}
- ~ReorderingOutput()
+ ~KhmerReorderingOutput()
{
// nothing to do here...
}
- void writeChar(LEUnicode ch, le_uint32 charIndex, const LETag *charTags)
+ void writeChar(LEUnicode ch, le_uint32 charIndex, FeatureMask charFeatures)
{
LEErrorCode success = LE_NO_ERROR;
fOutChars[fOutIndex] = ch;
fGlyphStorage.setCharIndex(fOutIndex, charIndex, success);
- fGlyphStorage.setAuxData(fOutIndex, (void *) charTags, NULL, success);
+ fGlyphStorage.setAuxData(fOutIndex, charFeatures, NULL, success);
fOutIndex += 1;
}
@@ -162,102 +163,67 @@ public:
};
-static const LETag emptyTag = 0x00000000; // ''
-//TODO remove unused flags
-//static const LETag nuktFeatureTag = LE_NUKT_FEATURE_TAG;
-//static const LETag akhnFeatureTag = LE_AKHN_FEATURE_TAG;
-//static const LETag rphfFeatureTag = LE_RPHF_FEATURE_TAG;
-static const LETag blwfFeatureTag = LE_BLWF_FEATURE_TAG;
-//static const LETag halfFeatureTag = LE_HALF_FEATURE_TAG;
-static const LETag pstfFeatureTag = LE_PSTF_FEATURE_TAG;
-//static const LETag vatuFeatureTag = LE_VATU_FEATURE_TAG;
-static const LETag presFeatureTag = LE_PRES_FEATURE_TAG;
-static const LETag blwsFeatureTag = LE_BLWS_FEATURE_TAG;
-static const LETag abvsFeatureTag = LE_ABVS_FEATURE_TAG;
-static const LETag pstsFeatureTag = LE_PSTS_FEATURE_TAG;
-//static const LETag halnFeatureTag = LE_HALN_FEATURE_TAG;
-
-static const LETag blwmFeatureTag = LE_BLWM_FEATURE_TAG;
-static const LETag abvmFeatureTag = LE_ABVM_FEATURE_TAG;
-static const LETag distFeatureTag = LE_DIST_FEATURE_TAG;
-
-static const LETag prefFeatureTag = LE_PREF_FEATURE_TAG;
-static const LETag abvfFeatureTag = LE_ABVF_FEATURE_TAG;
-static const LETag cligFeatureTag = LE_CLIG_FEATURE_TAG;
-static const LETag mkmkFeatureTag = LE_MKMK_FEATURE_TAG;
+#define blwfFeatureTag LE_BLWF_FEATURE_TAG
+#define pstfFeatureTag LE_PSTF_FEATURE_TAG
+#define presFeatureTag LE_PRES_FEATURE_TAG
+#define blwsFeatureTag LE_BLWS_FEATURE_TAG
+#define abvsFeatureTag LE_ABVS_FEATURE_TAG
+#define pstsFeatureTag LE_PSTS_FEATURE_TAG
+
+#define blwmFeatureTag LE_BLWM_FEATURE_TAG
+#define abvmFeatureTag LE_ABVM_FEATURE_TAG
+#define distFeatureTag LE_DIST_FEATURE_TAG
+
+#define prefFeatureTag LE_PREF_FEATURE_TAG
+#define abvfFeatureTag LE_ABVF_FEATURE_TAG
+#define cligFeatureTag LE_CLIG_FEATURE_TAG
+#define mkmkFeatureTag LE_MKMK_FEATURE_TAG
+
+#define prefFeatureMask 0x80000000UL
+#define blwfFeatureMask 0x40000000UL
+#define abvfFeatureMask 0x20000000UL
+#define pstfFeatureMask 0x10000000UL
+#define presFeatureMask 0x08000000UL
+#define blwsFeatureMask 0x04000000UL
+#define abvsFeatureMask 0x02000000UL
+#define pstsFeatureMask 0x01000000UL
+#define cligFeatureMask 0x00800000UL
+#define distFeatureMask 0x00400000UL
+#define blwmFeatureMask 0x00200000UL
+#define abvmFeatureMask 0x00100000UL
+#define mkmkFeatureMask 0x00080000UL
+
+#define tagPref (prefFeatureMask | presFeatureMask | cligFeatureMask | distFeatureMask)
+#define tagAbvf (abvfFeatureMask | abvsFeatureMask | cligFeatureMask | distFeatureMask | abvmFeatureMask | mkmkFeatureMask)
+#define tagPstf (blwfFeatureMask | blwsFeatureMask | prefFeatureMask | presFeatureMask | pstfFeatureMask | pstsFeatureMask | cligFeatureMask | distFeatureMask | blwmFeatureMask)
+#define tagBlwf (blwfFeatureMask | blwsFeatureMask | cligFeatureMask | distFeatureMask | blwmFeatureMask | mkmkFeatureMask)
+#define tagDefault (prefFeatureMask | blwfFeatureMask | presFeatureMask | blwsFeatureMask | cligFeatureMask | distFeatureMask | abvmFeatureMask | blwmFeatureMask | mkmkFeatureMask)
+
+
// These are in the order in which the features need to be applied
// for correct processing
-static const LETag featureOrder[] =
+static const FeatureMap featureMap[] =
{
// Shaping features
- prefFeatureTag, blwfFeatureTag, abvfFeatureTag, pstfFeatureTag,
- presFeatureTag, blwsFeatureTag, abvsFeatureTag, pstsFeatureTag,
- cligFeatureTag,
-
- // Positioning features
- distFeatureTag, blwmFeatureTag, abvmFeatureTag, mkmkFeatureTag,
- emptyTag
-};
-
-static const LETag tagPref[] =
-{
- prefFeatureTag, presFeatureTag,
- cligFeatureTag,
+ {prefFeatureTag, prefFeatureMask},
+ {blwfFeatureTag, blwfFeatureMask},
+ {abvfFeatureTag, abvfFeatureMask},
+ {pstfFeatureTag, pstfFeatureMask},
+ {presFeatureTag, presFeatureMask},
+ {blwsFeatureTag, blwsFeatureMask},
+ {abvsFeatureTag, abvsFeatureMask},
+ {pstsFeatureTag, pstsFeatureMask},
+ {cligFeatureTag, cligFeatureMask},
// Positioning features
- distFeatureTag,
- emptyTag
+ {distFeatureTag, distFeatureMask},
+ {blwmFeatureTag, blwmFeatureMask},
+ {abvmFeatureTag, abvmFeatureMask},
+ {mkmkFeatureTag, mkmkFeatureMask},
};
-static const LETag tagAbvf[] =
-{
- abvfFeatureTag, abvsFeatureTag,
- cligFeatureTag,
-
- // Positioning features
- distFeatureTag, abvmFeatureTag, mkmkFeatureTag,
- emptyTag
-};
-
-static const LETag tagPstf[] =
-{
- blwfFeatureTag, blwsFeatureTag,
- prefFeatureTag, presFeatureTag,
-
- pstfFeatureTag, pstsFeatureTag,
- cligFeatureTag,
-
- // Positioning features
- distFeatureTag, blwmFeatureTag,
- emptyTag
-};
-
-static const LETag tagBlwf[] =
-{
- blwfFeatureTag, blwsFeatureTag,
- cligFeatureTag,
-
- // Positioning features
- distFeatureTag, blwmFeatureTag, mkmkFeatureTag,
- emptyTag
-};
-
-
-// TODO do we need all of them?
-static const LETag tagDefault[] =
-{
- // Shaping feature
- prefFeatureTag, blwfFeatureTag, /*abvfFeatureTag,*/ /*pstfFeatureTag, */
- presFeatureTag, blwsFeatureTag, /*abvsFeatureTag,*/ /*pstsFeatureTag,*/
- cligFeatureTag,
-
- // Positioning features
- distFeatureTag, abvmFeatureTag, blwmFeatureTag, mkmkFeatureTag,
- emptyTag
-};
-
-
+static const le_int32 featureMapCount = LE_ARRAY_SIZE(featureMap);
// The stateTable is used to calculate the end (the length) of a well
// formed Khmer Syllable.
@@ -337,12 +303,12 @@ static const le_int8 khmerStateTable[][KhmerClassTable::CC_COUNT] =
{-1, -1, -1, -1, 12, 13, -1, 10, 16, 17, 1, 14}, // 9 - First consonant or type 3 after ceong
{-1, 11, 11, 11, -1, -1, -1, -1, -1, -1, -1, -1}, // 10 - Second Coeng (no register shifter before)
{-1, -1, -1, -1, 15, -1, -1, -1, 16, 17, 1, 14}, // 11 - Second coeng consonant (or ind. vowel) no register shifter before
- {-1, -1, 1, -1, -1, 13, -1, -1, 16, -1, -1, -1}, // 12 - Second ZWNJ before a register shifter
+ {-1, -1, -1, -1, -1, 13, -1, -1, 16, -1, -1, -1}, // 12 - Second ZWNJ before a register shifter
{-1, -1, -1, -1, 15, -1, -1, -1, 16, 17, 1, 14}, // 13 - Second register shifter
{-1, -1, -1, -1, -1, -1, -1, -1, 16, -1, -1, -1}, // 14 - ZWJ before vowel
{-1, -1, -1, -1, -1, -1, -1, -1, 16, -1, -1, -1}, // 15 - ZWNJ before vowel
{-1, -1, -1, -1, -1, -1, -1, -1, -1, 17, 1, 18}, // 16 - dependent vowel
- {-1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, 18}, // 17 - sign above
+ {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 18}, // 17 - sign above
{-1, -1, -1, -1, -1, -1, -1, 19, -1, -1, -1, -1}, // 18 - ZWJ after vowel
{-1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1}, // 19 - Third coeng
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1}, // 20 - dependent vowel after a Robat
@@ -350,9 +316,11 @@ static const le_int8 khmerStateTable[][KhmerClassTable::CC_COUNT] =
};
-const LETag *KhmerReordering::getFeatureOrder()
+const FeatureMap *KhmerReordering::getFeatureMap(le_int32 &count)
{
- return featureOrder;
+ count = featureMapCount;
+
+ return featureMap;
}
@@ -387,7 +355,7 @@ le_int32 KhmerReordering::reorder(const LEUnicode *chars, le_int32 charCount, le
{
const KhmerClassTable *classTable = KhmerClassTable::getKhmerClassTable();
- ReorderingOutput output(outChars, glyphStorage);
+ KhmerReorderingOutput output(outChars, glyphStorage);
KhmerClassTable::CharClass charClass;
le_int32 i, prev = 0, coengRo;
@@ -407,13 +375,13 @@ le_int32 KhmerReordering::reorder(const LEUnicode *chars, le_int32 charCount, le
// if a split vowel, write the pre part. In Khmer the pre part
// is the same for all split vowels, same glyph as pre vowel C_VOWEL_E
if (charClass & KhmerClassTable::CF_SPLIT_VOWEL) {
- output.writeChar(C_VOWEL_E, i, &tagPref[0]);
+ output.writeChar(C_VOWEL_E, i, tagPref);
break; // there can be only one vowel
}
// if a vowel with pos before write it out
if (charClass & KhmerClassTable::CF_POS_BEFORE) {
- output.writeChar(chars[i], i, &tagPref[0]);
+ output.writeChar(chars[i], i, tagPref);
break; // there can be only one vowel
}
@@ -430,8 +398,8 @@ le_int32 KhmerReordering::reorder(const LEUnicode *chars, le_int32 charCount, le
// write coeng + ro if found
if (coengRo > -1) {
- output.writeChar(C_COENG, coengRo, &tagPref[0]);
- output.writeChar(C_RO, coengRo + 1, &tagPref[0]);
+ output.writeChar(C_COENG, coengRo, tagPref);
+ output.writeChar(C_RO, coengRo + 1, tagPref);
}
// shall we add a dotted circle?
@@ -439,7 +407,7 @@ le_int32 KhmerReordering::reorder(const LEUnicode *chars, le_int32 charCount, le
// a character that has the Dotted circle flag (a character that cannot be a base)
// then write a dotted circle
if (classTable->getCharClass(chars[prev]) & KhmerClassTable::CF_DOTTED_CIRCLE) {
- output.writeChar(C_DOTTED_CIRCLE, prev, &tagDefault[0]);
+ output.writeChar(C_DOTTED_CIRCLE, prev, tagDefault);
}
// copy what is left to the output, skipping before vowels and coeng Ro if they are present
@@ -459,15 +427,15 @@ le_int32 KhmerReordering::reorder(const LEUnicode *chars, le_int32 charCount, le
switch (charClass & KhmerClassTable::CF_POS_MASK) {
case KhmerClassTable::CF_POS_ABOVE :
- output.writeChar(chars[i], i, &tagAbvf[0]);
+ output.writeChar(chars[i], i, tagAbvf);
break;
case KhmerClassTable::CF_POS_AFTER :
- output.writeChar(chars[i], i, &tagPstf[0]);
+ output.writeChar(chars[i], i, tagPstf);
break;
case KhmerClassTable::CF_POS_BELOW :
- output.writeChar(chars[i], i, &tagBlwf[0]);
+ output.writeChar(chars[i], i, tagBlwf);
break;
default:
@@ -476,14 +444,14 @@ le_int32 KhmerReordering::reorder(const LEUnicode *chars, le_int32 charCount, le
if ( (charClass & KhmerClassTable::CF_COENG) && i + 1 < syllable ) {
if ( (classTable->getCharClass(chars[i + 1]) & KhmerClassTable::CF_CLASS_MASK)
== KhmerClassTable::CC_CONSONANT3) {
- output.writeChar(chars[i], i, &tagPstf[0]);
+ output.writeChar(chars[i], i, tagPstf);
i += 1;
- output.writeChar(chars[i], i, &tagPstf[0]);
+ output.writeChar(chars[i], i, tagPstf);
}
else {
- output.writeChar(chars[i], i, &tagBlwf[0]);
+ output.writeChar(chars[i], i, tagBlwf);
i += 1;
- output.writeChar(chars[i], i, &tagBlwf[0]);
+ output.writeChar(chars[i], i, tagBlwf);
}
break;
}
@@ -502,13 +470,13 @@ le_int32 KhmerReordering::reorder(const LEUnicode *chars, le_int32 charCount, le
&& ( (classTable->getCharClass(chars[i + 3]) & KhmerClassTable::CF_CLASS_MASK) == C_VOWEL_AA)
&& ( (classTable->getCharClass(chars[i + 4]) & KhmerClassTable::CF_CLASS_MASK) == C_SIGN_NIKAHIT) ) )
{
- output.writeChar(chars[i], i, &tagBlwf[0]);
+ output.writeChar(chars[i], i, tagBlwf);
break;
}
}
// default - any other characters
- output.writeChar(chars[i], i, &tagDefault[0]);
+ output.writeChar(chars[i], i, tagDefault);
break;
} // switch
} // for