sl@0: /* sl@0: * sl@0: * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved sl@0: * sl@0: */ sl@0: sl@0: #ifndef __INDICREORDERING_H sl@0: #define __INDICREORDERING_H sl@0: sl@0: /** sl@0: * \file sl@0: * \internal sl@0: */ sl@0: sl@0: #include "LETypes.h" sl@0: #include "OpenTypeTables.h" sl@0: sl@0: U_NAMESPACE_BEGIN sl@0: sl@0: // Characters that get refered to by name... sl@0: #define C_SIGN_ZWNJ 0x200C sl@0: #define C_SIGN_ZWJ 0x200D sl@0: sl@0: // Character class values sl@0: #define CC_RESERVED 0U sl@0: #define CC_VOWEL_MODIFIER 1U sl@0: #define CC_STRESS_MARK 2U sl@0: #define CC_INDEPENDENT_VOWEL 3U sl@0: #define CC_INDEPENDENT_VOWEL_2 4U sl@0: #define CC_CONSONANT 5U sl@0: #define CC_CONSONANT_WITH_NUKTA 6U sl@0: #define CC_NUKTA 7U sl@0: #define CC_DEPENDENT_VOWEL 8U sl@0: #define CC_SPLIT_VOWEL_PIECE_1 9U sl@0: #define CC_SPLIT_VOWEL_PIECE_2 10U sl@0: #define CC_SPLIT_VOWEL_PIECE_3 11U sl@0: #define CC_VIRAMA 12U sl@0: #define CC_ZERO_WIDTH_MARK 13U sl@0: // Added by Nokia -- special case sl@0: #define CC_INDEPENDENT_VOWEL_A 14U sl@0: // Added by Nokia -- special case with independent vowel A sl@0: #define CC_DEPENDENT_VOWEL_CANDRA_E 15U sl@0: // Added by Nokia -- special case for Kannada Ra sl@0: #define CC_CONSONANT_KANNADA_BENGALI_RA 16U sl@0: // Added by Nokia -- special case for Tamil independent vowel O sl@0: #define CC_INDEPENDENT_VOWEL_TAMIL_O 17U sl@0: sl@0: // Added by Nokia -- special case for Gurmukhi Bearer ARA and independent A sl@0: #define CC_GUR_BEARER_A 18U sl@0: // Added by Nokia -- special case for Gurmukhi Bearer IRI sl@0: #define CC_GUR_BEARER_I 19U sl@0: // Added by Nokia -- special case for Gurmukhi Bearer URA sl@0: #define CC_GUR_BEARER_U 20U sl@0: sl@0: // Added by Nokia -- special case for Gurmukhi dependent Vowel which can combine with Bearer ARA sl@0: #define CC_GUR_DEPENDENT_VOWEL_A 21U sl@0: // Added by Nokia -- special case for Gurmukhi dependent Vowel which can combine with Bearer IRI sl@0: #define CC_GUR_DEPENDENT_VOWEL_I 22U sl@0: // Added by Nokia -- special case for Gurmukhi dependent Vowel which can combine with Bearer URA sl@0: #define CC_GUR_DEPENDENT_VOWEL_U 23U sl@0: sl@0: #define CC_COUNT 24U sl@0: sl@0: // Character class flags sl@0: #define CF_CLASS_MASK 0x0000FFFFU sl@0: sl@0: #define CF_CONSONANT 0x80000000U sl@0: sl@0: #define CF_REPH 0x40000000U sl@0: #define CF_VATTU 0x20000000U sl@0: #define CF_BELOW_BASE 0x10000000U sl@0: #define CF_POST_BASE 0x08000000U sl@0: #define CF_LENGTH_MARK 0x04000000U sl@0: // Added by Nokia -- special case for Bengali Ya sl@0: #define CF_CONSONANT_BENGALI_YA 0x00800000U sl@0: sl@0: // Added by Nokia -- 1922 Malayalam Chillu --> sl@0: #define CF_CONSONANT_MLYL_CHILLU 0x00400000U sl@0: #define CC_DEPENDENT_VOWEL_SIGN_MLYL_E 0xD46U sl@0: #define CC_CONSONANT_MLYL_YA 0xD2FU sl@0: #define CC_CONSONANT_MLYL_VA 0xD35U sl@0: #define CC_CONSONANT_MLYL_RA 0xD30U sl@0: #define CC_CONSONANT_MLYL_RRA 0xD31U sl@0: #define CC_CONSONANT_MLYL_LLA 0xD33U sl@0: #define CC_CONSONANT_MLYL_LLLA 0xD34U sl@0: // <-- 1922 mlyl sl@0: sl@0: #define CF_POS_BEFORE 0x00300000U sl@0: #define CF_POS_BELOW 0x00200000U sl@0: #define CF_POS_ABOVE 0x00100000U sl@0: #define CF_POS_AFTER 0x00000000U sl@0: #define CF_POS_MASK 0x00300000U sl@0: sl@0: #define CF_INDEX_MASK 0x000F0000U sl@0: #define CF_INDEX_SHIFT 16 sl@0: sl@0: // Script flag bits sl@0: #define SF_MATRAS_AFTER_BASE 0x80000000U sl@0: #define SF_REPH_AFTER_BELOW 0x40000000U sl@0: #define SF_EYELASH_RA 0x20000000U sl@0: #define SF_MPRE_FIXUP 0x10000000U sl@0: //Added by Nokia for matra combined with final form of YA in Gurmukhi sl@0: //Flags SF_MATRAS_AFTER_BASE and SF_MATRAS_AFTER_POSTBASE cannot coexist. sl@0: //with SF_MATRAS_AFTER_BASE setting: Mbelow, Mabove and Mpost are attached to base consonant. sl@0: //With SF_MATRAS_AFTER_AFTERBASE setting: Mbelow, Mabove and Mpost are attached to postbase consonant sl@0: //without SF_MATRAS_AFTER_BASE or SF_MATRAS_AFTER_AFTERBASE setting: Mbelow, Mabove are attached to sl@0: //base (or base+below-base consonant cluster), but Mpost attached to postbase sl@0: #define SF_MATRAS_AFTER_POSTBASE 0x08000000U sl@0: sl@0: #define SF_POST_BASE_LIMIT_MASK 0x0000FFFFU sl@0: #define SF_NO_POST_BASE_LIMIT 0x00007FFFU sl@0: sl@0: typedef LEUnicode SplitMatra[3]; sl@0: sl@0: class MPreFixups; sl@0: class LEGlyphStorage; sl@0: sl@0: struct IndicClassTable sl@0: { sl@0: typedef le_uint32 CharClass; sl@0: typedef le_uint32 ScriptFlags; sl@0: sl@0: LEUnicode firstChar; sl@0: LEUnicode lastChar; sl@0: le_int32 worstCaseExpansion; sl@0: ScriptFlags scriptFlags; sl@0: const CharClass *classTable; sl@0: const SplitMatra *splitMatraTable; sl@0: sl@0: inline le_int32 getWorstCaseExpansion() const; sl@0: sl@0: CharClass getCharClass(LEUnicode ch) const; sl@0: sl@0: inline const SplitMatra *getSplitMatra(CharClass charClass) const; sl@0: sl@0: inline le_bool isVowelModifier(LEUnicode ch) const; sl@0: inline le_bool isStressMark(LEUnicode ch) const; sl@0: inline le_bool isConsonant(LEUnicode ch) const; sl@0: inline le_bool isReph(LEUnicode ch) const; sl@0: inline le_bool isVirama(LEUnicode ch) const; sl@0: inline le_bool isNukta(LEUnicode ch) const; sl@0: inline le_bool isVattu(LEUnicode ch) const; sl@0: inline le_bool isMatra(LEUnicode ch) const; sl@0: inline le_bool isSplitMatra(LEUnicode ch) const; sl@0: inline le_bool isLengthMark(LEUnicode ch) const; sl@0: inline le_bool hasPostOrBelowBaseForm(LEUnicode ch) const; sl@0: inline le_bool hasPostBaseForm(LEUnicode ch) const; sl@0: inline le_bool hasBelowBaseForm(LEUnicode ch) const; sl@0: // Added by Nokia: For special case Bengali Ya sl@0: inline le_bool isBengaliYa(LEUnicode ch) const; sl@0: // Added by Nokia -- 1922 mlyl --> sl@0: inline le_bool isMlylChillu(LEUnicode ch) const; sl@0: // <-- 1922 mlyl sl@0: sl@0: inline static le_bool isVowelModifier(CharClass charClass); sl@0: inline static le_bool isStressMark(CharClass charClass); sl@0: inline static le_bool isConsonant(CharClass charClass); sl@0: inline static le_bool isReph(CharClass charClass); sl@0: inline static le_bool isVirama(CharClass charClass); sl@0: inline static le_bool isNukta(CharClass charClass); sl@0: inline static le_bool isVattu(CharClass charClass); sl@0: inline static le_bool isMatra(CharClass charClass); sl@0: inline static le_bool isSplitMatra(CharClass charClass); sl@0: inline static le_bool isLengthMark(CharClass charClass); sl@0: inline static le_bool hasPostOrBelowBaseForm(CharClass charClass); sl@0: inline static le_bool hasPostBaseForm(CharClass charClass); sl@0: inline static le_bool hasBelowBaseForm(CharClass charClass); sl@0: // Added by Nokia: For special case Bengali Ya sl@0: inline static le_bool isBengaliYa(CharClass charClass); sl@0: // Added by Nokia -- 1922 mlyl --> sl@0: inline static le_bool isMlylChillu(CharClass charClass); sl@0: // <-- 1922 mlyl sl@0: sl@0: static const IndicClassTable *getScriptClassTable(le_int32 scriptCode); sl@0: }; sl@0: sl@0: class IndicReordering /* not : public UObject because all methods are static */ { sl@0: public: sl@0: static le_int32 getWorstCaseExpansion(le_int32 scriptCode); sl@0: sl@0: static le_int32 reorder(const LEUnicode *theChars, le_int32 charCount, le_int32 scriptCode, sl@0: LEUnicode *outChars, LEGlyphStorage &glyphStorage, sl@0: MPreFixups **outMPreFixups, LEErrorCode& success); sl@0: sl@0: static void adjustMPres(MPreFixups *mpreFixups, LEGlyphStorage &glyphStorage, sl@0: LEErrorCode& success); sl@0: sl@0: static const LETag *getFeatureOrder(); sl@0: sl@0: private: sl@0: // do not instantiate sl@0: IndicReordering(); sl@0: sl@0: static le_int32 findSyllable(const IndicClassTable *classTable, const LEUnicode *chars, le_int32 prev, le_int32 charCount); sl@0: sl@0: }; sl@0: sl@0: inline le_int32 IndicClassTable::getWorstCaseExpansion() const sl@0: { sl@0: return worstCaseExpansion; sl@0: } sl@0: sl@0: inline const SplitMatra *IndicClassTable::getSplitMatra(CharClass charClass) const sl@0: { sl@0: le_int32 index = (charClass & CF_INDEX_MASK) >> CF_INDEX_SHIFT; sl@0: sl@0: return &splitMatraTable[index - 1]; sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isVowelModifier(CharClass charClass) sl@0: { sl@0: return (charClass & CF_CLASS_MASK) == CC_VOWEL_MODIFIER; sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isStressMark(CharClass charClass) sl@0: { sl@0: return (charClass & CF_CLASS_MASK) == CC_STRESS_MARK; sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isConsonant(CharClass charClass) sl@0: { sl@0: return (charClass & CF_CONSONANT) != 0; sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isReph(CharClass charClass) sl@0: { sl@0: return (charClass & CF_REPH) != 0; sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isNukta(CharClass charClass) sl@0: { sl@0: return (charClass & CF_CLASS_MASK) == CC_NUKTA; sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isVirama(CharClass charClass) sl@0: { sl@0: return (charClass & CF_CLASS_MASK) == CC_VIRAMA; sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isVattu(CharClass charClass) sl@0: { sl@0: return (charClass & CF_VATTU) != 0; sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isMatra(CharClass charClass) sl@0: { sl@0: charClass &= CF_CLASS_MASK; sl@0: sl@0: // Added special CANDRA E char class check to enable formation of Devanagari CANDRA A sl@0: // Added speical CC_GUR_DEPENDENT_VOWEL_* to support decompositions of the independent sl@0: // vowels into a sequence of a vowel bearer and a depending vowel sign sl@0: return charClass >= CC_DEPENDENT_VOWEL && charClass <= CC_SPLIT_VOWEL_PIECE_3 sl@0: || charClass == CC_DEPENDENT_VOWEL_CANDRA_E sl@0: || charClass == CC_GUR_DEPENDENT_VOWEL_A sl@0: || charClass == CC_GUR_DEPENDENT_VOWEL_I sl@0: || charClass == CC_GUR_DEPENDENT_VOWEL_U; sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isSplitMatra(CharClass charClass) sl@0: { sl@0: return (charClass & CF_INDEX_MASK) != 0; sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isLengthMark(CharClass charClass) sl@0: { sl@0: return (charClass & CF_LENGTH_MARK) != 0; sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::hasPostOrBelowBaseForm(CharClass charClass) sl@0: { sl@0: return (charClass & (CF_POST_BASE | CF_BELOW_BASE)) != 0; sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::hasPostBaseForm(CharClass charClass) sl@0: { sl@0: return (charClass & CF_POST_BASE) != 0; sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::hasBelowBaseForm(CharClass charClass) sl@0: { sl@0: return (charClass & CF_BELOW_BASE) != 0; sl@0: } sl@0: sl@0: // Added by Nokia -- For determining whether a character is a Bengali Ya sl@0: inline le_bool IndicClassTable::isBengaliYa(CharClass charClass) sl@0: { sl@0: return (charClass & CF_CONSONANT_BENGALI_YA) != 0; sl@0: } sl@0: sl@0: // Added by Nokia -- 1922 mlyl --> sl@0: inline le_bool IndicClassTable::isMlylChillu(CharClass charClass) sl@0: { sl@0: return (charClass & CF_CONSONANT_MLYL_CHILLU) != 0; sl@0: } sl@0: // <-- 1922 mlyl sl@0: sl@0: inline le_bool IndicClassTable::isVowelModifier(LEUnicode ch) const sl@0: { sl@0: return isVowelModifier(getCharClass(ch)); sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isStressMark(LEUnicode ch) const sl@0: { sl@0: return isStressMark(getCharClass(ch)); sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isConsonant(LEUnicode ch) const sl@0: { sl@0: return isConsonant(getCharClass(ch)); sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isReph(LEUnicode ch) const sl@0: { sl@0: return isReph(getCharClass(ch)); sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isVirama(LEUnicode ch) const sl@0: { sl@0: return isVirama(getCharClass(ch)); sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isNukta(LEUnicode ch) const sl@0: { sl@0: return isNukta(getCharClass(ch)); sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isVattu(LEUnicode ch) const sl@0: { sl@0: return isVattu(getCharClass(ch)); sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isMatra(LEUnicode ch) const sl@0: { sl@0: return isMatra(getCharClass(ch)); sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isSplitMatra(LEUnicode ch) const sl@0: { sl@0: return isSplitMatra(getCharClass(ch)); sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::isLengthMark(LEUnicode ch) const sl@0: { sl@0: return isLengthMark(getCharClass(ch)); sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::hasPostOrBelowBaseForm(LEUnicode ch) const sl@0: { sl@0: return hasPostOrBelowBaseForm(getCharClass(ch)); sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::hasPostBaseForm(LEUnicode ch) const sl@0: { sl@0: return hasPostBaseForm(getCharClass(ch)); sl@0: } sl@0: sl@0: inline le_bool IndicClassTable::hasBelowBaseForm(LEUnicode ch) const sl@0: { sl@0: return hasBelowBaseForm(getCharClass(ch)); sl@0: } sl@0: sl@0: // Added by Nokia -- For determining whether a character is a Bengali Ya sl@0: inline le_bool IndicClassTable::isBengaliYa(LEUnicode ch) const sl@0: { sl@0: return isBengaliYa(getCharClass(ch)); sl@0: } sl@0: sl@0: // Added by Nokia -- 1922 mlyl --> sl@0: inline le_bool IndicClassTable::isMlylChillu(LEUnicode ch) const sl@0: { sl@0: return isMlylChillu(getCharClass(ch)); sl@0: } sl@0: // <-- 1922 mlyl sl@0: sl@0: U_NAMESPACE_END sl@0: #endif