X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b75a7d8f3b4adbae880cab104ce2c6a50eee4db2..08b89b0a244153b9f5bbb2f49c55ab0f7298122e:/icuSources/layout/IndicReordering.h?ds=sidebyside diff --git a/icuSources/layout/IndicReordering.h b/icuSources/layout/IndicReordering.h index 50cea02b..8b2fdfa5 100644 --- a/icuSources/layout/IndicReordering.h +++ b/icuSources/layout/IndicReordering.h @@ -1,9 +1,6 @@ /* - * (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved * - * $Source: /cvs/root/ICU/icuSources/layout/IndicReordering.h,v $ - * $Date: 2003/07/03 18:13:45 $ - * $Revision: 1.1.1.2 $ + * (C) Copyright IBM Corp. 1998-2011 - All Rights Reserved * */ @@ -21,68 +18,80 @@ U_NAMESPACE_BEGIN // Characters that get refered to by name... -enum -{ - C_SIGN_ZWNJ = 0x200C, - C_SIGN_ZWJ = 0x200D -}; - -typedef LEUnicode SplitMatra[3]; - -class MPreFixups; +#define C_SIGN_ZWNJ 0x200C +#define C_SIGN_ZWJ 0x200D + +// Character class values +#define CC_RESERVED 0U +#define CC_VOWEL_MODIFIER 1U +#define CC_STRESS_MARK 2U +#define CC_INDEPENDENT_VOWEL 3U +#define CC_INDEPENDENT_VOWEL_2 4U +#define CC_INDEPENDENT_VOWEL_3 5U +#define CC_CONSONANT 6U +#define CC_CONSONANT_WITH_NUKTA 7U +#define CC_NUKTA 8U +#define CC_DEPENDENT_VOWEL 9U +#define CC_SPLIT_VOWEL_PIECE_1 10U +#define CC_SPLIT_VOWEL_PIECE_2 11U +#define CC_SPLIT_VOWEL_PIECE_3 12U +#define CC_VIRAMA 13U +#define CC_ZERO_WIDTH_MARK 14U +#define CC_AL_LAKUNA 15U +#define CC_COUNT 16U + +// Character class flags +#define CF_CLASS_MASK 0x0000FFFFU + +#define CF_CONSONANT 0x80000000U + +#define CF_REPH 0x40000000U +#define CF_VATTU 0x20000000U +#define CF_BELOW_BASE 0x10000000U +#define CF_POST_BASE 0x08000000U +#define CF_LENGTH_MARK 0x04000000U +#define CF_PRE_BASE 0x02000000U + +#define CF_POS_BEFORE 0x00300000U +#define CF_POS_BELOW 0x00200000U +#define CF_POS_ABOVE 0x00100000U +#define CF_POS_AFTER 0x00000000U +#define CF_POS_MASK 0x00300000U + +#define CF_INDEX_MASK 0x000F0000U +#define CF_INDEX_SHIFT 16 + +// Script flag bits +#define SF_MATRAS_AFTER_BASE 0x80000000U +#define SF_REPH_AFTER_BELOW 0x40000000U +#define SF_EYELASH_RA 0x20000000U +#define SF_MPRE_FIXUP 0x10000000U +#define SF_FILTER_ZERO_WIDTH 0x08000000U + +#define SF_POST_BASE_LIMIT_MASK 0x0000FFFFU +#define SF_NO_POST_BASE_LIMIT 0x00007FFFU + +#define SM_MAX_PIECES 3 + +typedef LEUnicode SplitMatra[SM_MAX_PIECES]; + +class MPreFixups; +class LEGlyphStorage; + +// Dynamic Properties ( v2 fonts only ) +typedef le_uint32 DynamicProperties; + +#define DP_REPH 0x80000000U +#define DP_HALF 0x40000000U +#define DP_PREF 0x20000000U +#define DP_BLWF 0x10000000U +#define DP_PSTF 0x08000000U struct IndicClassTable { - enum CharClassValues - { - CC_RESERVED = 0, - CC_MODIFYING_MARK_ABOVE = 1, - CC_MODIFYING_MARK_POST = 2, - CC_INDEPENDENT_VOWEL = 3, - CC_CONSONANT = 4, - CC_CONSONANT_WITH_NUKTA = 5, - CC_NUKTA = 6, - CC_DEPENDENT_VOWEL = 7, - CC_VIRAMA = 8, - CC_ZERO_WIDTH_MARK = 9, - CC_COUNT = 10 - }; - - enum CharClassFlags - { - CF_CLASS_MASK = 0x0000FFFF, - - CF_CONSONANT = 0x80000000, - - CF_REPH = 0x40000000, - CF_VATTU = 0x20000000, - CF_BELOW_BASE = 0x10000000, - CF_POST_BASE = 0x08000000, - - CF_MATRA_PRE = 0x04000000, - CF_MATRA_BELOW = 0x02000000, - CF_MATRA_ABOVE = 0x01000000, - CF_MATRA_POST = 0x00800000, - CF_LENGTH_MARK = 0x00400000, - CF_INDEX_MASK = 0x000F0000, - CF_INDEX_SHIFT = 16 - }; - - typedef le_int32 CharClass; - - enum ScriptFlagBits - { - SF_MATRAS_AFTER_BASE = 0x80000000, - SF_REPH_AFTER_BELOW = 0x40000000, - SF_EYELASH_RA = 0x20000000, - SF_MPRE_FIXUP = 0x10000000, - - SF_POST_BASE_LIMIT_MASK = 0x0000FFFF, - SF_NO_POST_BASE_LIMIT = 0x00007FFF - }; - - typedef le_int32 ScriptFlags; - + typedef le_uint32 CharClass; + typedef le_uint32 ScriptFlags; + LEUnicode firstChar; LEUnicode lastChar; le_int32 worstCaseExpansion; @@ -90,46 +99,46 @@ struct IndicClassTable const CharClass *classTable; const SplitMatra *splitMatraTable; - le_int32 getWorstCaseExpansion() const; + inline le_int32 getWorstCaseExpansion() const; + inline le_bool getFilterZeroWidth() const; CharClass getCharClass(LEUnicode ch) const; - const SplitMatra *getSplitMatra(CharClass charClass) const; - - le_bool isVMabove(LEUnicode ch) const; - le_bool isVMpost(LEUnicode ch) const; - le_bool isConsonant(LEUnicode ch) const; - le_bool isReph(LEUnicode ch) const; - le_bool isVirama(LEUnicode ch) const; - le_bool isNukta(LEUnicode ch) const; - le_bool isVattu(LEUnicode ch) const; - le_bool isMatra(LEUnicode ch) const; - le_bool isSplitMatra(LEUnicode ch) const; - le_bool isMpre(LEUnicode ch) const; - le_bool isMbelow(LEUnicode ch) const; - le_bool isMabove(LEUnicode ch) const; - le_bool isMpost(LEUnicode ch) const; - le_bool isLengthMark(LEUnicode ch) const; - le_bool hasPostOrBelowBaseForm(LEUnicode ch) const; - le_bool hasPostBaseForm(LEUnicode ch) const; - le_bool hasBelowBaseForm(LEUnicode ch) const; - - static le_bool isVMabove(CharClass charClass); - static le_bool isVMpost(CharClass charClass); - static le_bool isConsonant(CharClass charClass); - static le_bool isReph(CharClass charClass); - static le_bool isVirama(CharClass charClass); - static le_bool isNukta(CharClass charClass); - static le_bool isVattu(CharClass charClass); - static le_bool isMatra(CharClass charClass); - static le_bool isSplitMatra(CharClass charClass); - static le_bool isMpre(CharClass charClass); - static le_bool isMbelow(CharClass charClass); - static le_bool isMabove(CharClass charClass); - static le_bool isMpost(CharClass charClass); - static le_bool isLengthMark(CharClass charClass); - static le_bool hasPostOrBelowBaseForm(CharClass charClass); - static le_bool hasPostBaseForm(CharClass charClass); - static le_bool hasBelowBaseForm(CharClass charClass); + + inline const SplitMatra *getSplitMatra(CharClass charClass) const; + + inline le_bool isVowelModifier(LEUnicode ch) const; + inline le_bool isStressMark(LEUnicode ch) const; + inline le_bool isConsonant(LEUnicode ch) const; + inline le_bool isReph(LEUnicode ch) const; + inline le_bool isVirama(LEUnicode ch) const; + inline le_bool isAlLakuna(LEUnicode ch) const; + inline le_bool isNukta(LEUnicode ch) const; + inline le_bool isVattu(LEUnicode ch) const; + inline le_bool isMatra(LEUnicode ch) const; + inline le_bool isSplitMatra(LEUnicode ch) const; + inline le_bool isLengthMark(LEUnicode ch) const; + inline le_bool hasPostOrBelowBaseForm(LEUnicode ch) const; + inline le_bool hasPostBaseForm(LEUnicode ch) const; + inline le_bool hasBelowBaseForm(LEUnicode ch) const; + inline le_bool hasAboveBaseForm(LEUnicode ch) const; + inline le_bool hasPreBaseForm(LEUnicode ch) const; + + inline static le_bool isVowelModifier(CharClass charClass); + inline static le_bool isStressMark(CharClass charClass); + inline static le_bool isConsonant(CharClass charClass); + inline static le_bool isReph(CharClass charClass); + inline static le_bool isVirama(CharClass charClass); + inline static le_bool isAlLakuna(CharClass charClass); + inline static le_bool isNukta(CharClass charClass); + inline static le_bool isVattu(CharClass charClass); + inline static le_bool isMatra(CharClass charClass); + inline static le_bool isSplitMatra(CharClass charClass); + inline static le_bool isLengthMark(CharClass charClass); + inline static le_bool hasPostOrBelowBaseForm(CharClass charClass); + inline static le_bool hasPostBaseForm(CharClass charClass); + inline static le_bool hasBelowBaseForm(CharClass charClass); + inline static le_bool hasAboveBaseForm(CharClass charClass); + inline static le_bool hasPreBaseForm(CharClass charClass); static const IndicClassTable *getScriptClassTable(le_int32 scriptCode); }; @@ -138,13 +147,26 @@ class IndicReordering /* not : public UObject because all methods are static */ public: static le_int32 getWorstCaseExpansion(le_int32 scriptCode); + static le_bool getFilterZeroWidth(le_int32 scriptCode); + static le_int32 reorder(const LEUnicode *theChars, le_int32 charCount, le_int32 scriptCode, - LEUnicode *outChars, le_int32 *charIndices, const LETag **charTags, - MPreFixups **outMPreFixups); + LEUnicode *outChars, LEGlyphStorage &glyphStorage, + MPreFixups **outMPreFixups, LEErrorCode& success); + + static void adjustMPres(MPreFixups *mpreFixups, LEGlyphStorage &glyphStorage, LEErrorCode& success); - static void adjustMPres(MPreFixups *mpreFixups, LEGlyphID *glyphs, le_int32 *charIndices); + static le_int32 v2process(const LEUnicode *theChars, le_int32 charCount, le_int32 scriptCode, + LEUnicode *outChars, LEGlyphStorage &glyphStorage); - static const LETag *getFeatureOrder(); + static const FeatureMap *getFeatureMap(le_int32 &count); + + static const FeatureMap *getv2FeatureMap(le_int32 &count); + + static void applyPresentationForms(LEGlyphStorage &glyphStorage, le_int32 count); + + static void finalReordering(LEGlyphStorage &glyphStorage, le_int32 count); + + static void getDynamicProperties(DynamicProperties *dProps, const IndicClassTable *classTable); private: // do not instantiate @@ -159,6 +181,11 @@ inline le_int32 IndicClassTable::getWorstCaseExpansion() const return worstCaseExpansion; } +inline le_bool IndicClassTable::getFilterZeroWidth() const +{ + return (scriptFlags & SF_FILTER_ZERO_WIDTH) != 0; +} + inline const SplitMatra *IndicClassTable::getSplitMatra(CharClass charClass) const { le_int32 index = (charClass & CF_INDEX_MASK) >> CF_INDEX_SHIFT; @@ -166,14 +193,14 @@ inline const SplitMatra *IndicClassTable::getSplitMatra(CharClass charClass) con return &splitMatraTable[index - 1]; } -inline le_bool IndicClassTable::isVMabove(CharClass charClass) +inline le_bool IndicClassTable::isVowelModifier(CharClass charClass) { - return (charClass & CF_CLASS_MASK) == CC_MODIFYING_MARK_ABOVE; + return (charClass & CF_CLASS_MASK) == CC_VOWEL_MODIFIER; } -inline le_bool IndicClassTable::isVMpost(CharClass charClass) +inline le_bool IndicClassTable::isStressMark(CharClass charClass) { - return (charClass & CF_CLASS_MASK) == CC_MODIFYING_MARK_POST; + return (charClass & CF_CLASS_MASK) == CC_STRESS_MARK; } inline le_bool IndicClassTable::isConsonant(CharClass charClass) @@ -196,6 +223,11 @@ inline le_bool IndicClassTable::isVirama(CharClass charClass) return (charClass & CF_CLASS_MASK) == CC_VIRAMA; } +inline le_bool IndicClassTable::isAlLakuna(CharClass charClass) +{ + return (charClass & CF_CLASS_MASK) == CC_AL_LAKUNA; +} + inline le_bool IndicClassTable::isVattu(CharClass charClass) { return (charClass & CF_VATTU) != 0; @@ -203,7 +235,9 @@ inline le_bool IndicClassTable::isVattu(CharClass charClass) inline le_bool IndicClassTable::isMatra(CharClass charClass) { - return (charClass & CF_CLASS_MASK) == CC_DEPENDENT_VOWEL; + charClass &= CF_CLASS_MASK; + + return charClass >= CC_DEPENDENT_VOWEL && charClass <= CC_SPLIT_VOWEL_PIECE_3; } inline le_bool IndicClassTable::isSplitMatra(CharClass charClass) @@ -211,26 +245,6 @@ inline le_bool IndicClassTable::isSplitMatra(CharClass charClass) return (charClass & CF_INDEX_MASK) != 0; } -inline le_bool IndicClassTable::isMpre(CharClass charClass) -{ - return (charClass & CF_MATRA_PRE) != 0; -} - -inline le_bool IndicClassTable::isMbelow(CharClass charClass) -{ - return (charClass & CF_MATRA_BELOW) != 0; -} - -inline le_bool IndicClassTable::isMabove(CharClass charClass) -{ - return (charClass & CF_MATRA_ABOVE) != 0; -} - -inline le_bool IndicClassTable::isMpost(CharClass charClass) -{ - return (charClass & CF_MATRA_POST) != 0; -} - inline le_bool IndicClassTable::isLengthMark(CharClass charClass) { return (charClass & CF_LENGTH_MARK) != 0; @@ -246,19 +260,29 @@ inline le_bool IndicClassTable::hasPostBaseForm(CharClass charClass) return (charClass & CF_POST_BASE) != 0; } +inline le_bool IndicClassTable::hasPreBaseForm(CharClass charClass) +{ + return (charClass & CF_PRE_BASE) != 0; +} + inline le_bool IndicClassTable::hasBelowBaseForm(CharClass charClass) { return (charClass & CF_BELOW_BASE) != 0; } -inline le_bool IndicClassTable::isVMabove(LEUnicode ch) const +inline le_bool IndicClassTable::hasAboveBaseForm(CharClass charClass) +{ + return ((charClass & CF_POS_MASK) == CF_POS_ABOVE); +} + +inline le_bool IndicClassTable::isVowelModifier(LEUnicode ch) const { - return isVMabove(getCharClass(ch)); + return isVowelModifier(getCharClass(ch)); } -inline le_bool IndicClassTable::isVMpost(LEUnicode ch) const +inline le_bool IndicClassTable::isStressMark(LEUnicode ch) const { - return isVMpost(getCharClass(ch)); + return isStressMark(getCharClass(ch)); } inline le_bool IndicClassTable::isConsonant(LEUnicode ch) const @@ -276,6 +300,11 @@ inline le_bool IndicClassTable::isVirama(LEUnicode ch) const return isVirama(getCharClass(ch)); } +inline le_bool IndicClassTable::isAlLakuna(LEUnicode ch) const +{ + return isAlLakuna(getCharClass(ch)); +} + inline le_bool IndicClassTable::isNukta(LEUnicode ch) const { return isNukta(getCharClass(ch)); @@ -296,26 +325,6 @@ inline le_bool IndicClassTable::isSplitMatra(LEUnicode ch) const return isSplitMatra(getCharClass(ch)); } -inline le_bool IndicClassTable::isMpre(LEUnicode ch) const -{ - return isMpre(getCharClass(ch)); -} - -inline le_bool IndicClassTable::isMbelow(LEUnicode ch) const -{ - return isMbelow(getCharClass(ch)); -} - -inline le_bool IndicClassTable::isMabove(LEUnicode ch) const -{ - return isMabove(getCharClass(ch)); -} - -inline le_bool IndicClassTable::isMpost(LEUnicode ch) const -{ - return isMpost(getCharClass(ch)); -} - inline le_bool IndicClassTable::isLengthMark(LEUnicode ch) const { return isLengthMark(getCharClass(ch)); @@ -336,5 +345,14 @@ inline le_bool IndicClassTable::hasBelowBaseForm(LEUnicode ch) const return hasBelowBaseForm(getCharClass(ch)); } +inline le_bool IndicClassTable::hasPreBaseForm(LEUnicode ch) const +{ + return hasPreBaseForm(getCharClass(ch)); +} + +inline le_bool IndicClassTable::hasAboveBaseForm(LEUnicode ch) const +{ + return hasAboveBaseForm(getCharClass(ch)); +} U_NAMESPACE_END #endif