2000-11-28 20:56:52 +00:00
|
|
|
/*
|
2004-04-12 18:51:31 +00:00
|
|
|
*
|
2008-05-27 22:44:40 +00:00
|
|
|
* (C) Copyright IBM Corp. 1998-2008 - All Rights Reserved
|
2004-04-12 18:51:31 +00:00
|
|
|
*
|
2000-11-28 20:56:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __INDICREORDERING_H
|
|
|
|
#define __INDICREORDERING_H
|
|
|
|
|
2003-01-13 23:15:11 +00:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* \internal
|
|
|
|
*/
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
#include "LETypes.h"
|
|
|
|
#include "OpenTypeTables.h"
|
|
|
|
|
2001-10-16 00:39:01 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
// Characters that get refered to by name...
|
2005-06-17 19:20:43 +00:00
|
|
|
#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
|
2005-07-28 21:27:12 +00:00
|
|
|
#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
|
2008-05-27 22:44:40 +00:00
|
|
|
#define CC_AL_LAKUNA 15U
|
|
|
|
#define CC_COUNT 16U
|
2005-06-17 19:20:43 +00:00
|
|
|
|
|
|
|
// 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_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
|
2005-09-02 18:22:09 +00:00
|
|
|
#define SF_FILTER_ZERO_WIDTH 0x08000000U
|
2005-06-17 19:20:43 +00:00
|
|
|
|
|
|
|
#define SF_POST_BASE_LIMIT_MASK 0x0000FFFFU
|
|
|
|
#define SF_NO_POST_BASE_LIMIT 0x00007FFFU
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
typedef LEUnicode SplitMatra[3];
|
|
|
|
|
2004-04-12 18:51:31 +00:00
|
|
|
class MPreFixups;
|
|
|
|
class LEGlyphStorage;
|
2003-01-04 02:52:23 +00:00
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
struct IndicClassTable
|
|
|
|
{
|
2003-11-25 23:41:24 +00:00
|
|
|
typedef le_uint32 CharClass;
|
2005-06-17 19:20:43 +00:00
|
|
|
typedef le_uint32 ScriptFlags;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
LEUnicode firstChar;
|
|
|
|
LEUnicode lastChar;
|
|
|
|
le_int32 worstCaseExpansion;
|
|
|
|
ScriptFlags scriptFlags;
|
|
|
|
const CharClass *classTable;
|
|
|
|
const SplitMatra *splitMatraTable;
|
|
|
|
|
2005-02-26 00:40:09 +00:00
|
|
|
inline le_int32 getWorstCaseExpansion() const;
|
2005-09-02 18:22:09 +00:00
|
|
|
inline le_bool getFilterZeroWidth() const;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
CharClass getCharClass(LEUnicode ch) const;
|
2005-02-26 00:40:09 +00:00
|
|
|
|
|
|
|
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;
|
2008-05-27 22:44:40 +00:00
|
|
|
inline le_bool isAlLakuna(LEUnicode ch) const;
|
2005-02-26 00:40:09 +00:00
|
|
|
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 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);
|
2008-05-27 22:44:40 +00:00
|
|
|
inline static le_bool isAlLakuna(CharClass charClass);
|
2005-02-26 00:40:09 +00:00
|
|
|
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);
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
static const IndicClassTable *getScriptClassTable(le_int32 scriptCode);
|
|
|
|
};
|
|
|
|
|
2002-06-29 00:04:16 +00:00
|
|
|
class IndicReordering /* not : public UObject because all methods are static */ {
|
2000-11-28 20:56:52 +00:00
|
|
|
public:
|
|
|
|
static le_int32 getWorstCaseExpansion(le_int32 scriptCode);
|
|
|
|
|
2005-09-02 18:22:09 +00:00
|
|
|
static le_bool getFilterZeroWidth(le_int32 scriptCode);
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
static le_int32 reorder(const LEUnicode *theChars, le_int32 charCount, le_int32 scriptCode,
|
2004-04-12 18:51:31 +00:00
|
|
|
LEUnicode *outChars, LEGlyphStorage &glyphStorage,
|
2003-01-04 02:52:23 +00:00
|
|
|
MPreFixups **outMPreFixups);
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2004-04-12 18:51:31 +00:00
|
|
|
static void adjustMPres(MPreFixups *mpreFixups, LEGlyphStorage &glyphStorage);
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2005-08-06 00:48:27 +00:00
|
|
|
static const FeatureMap *getFeatureMap(le_int32 &count);
|
2002-03-01 22:24:10 +00:00
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
private:
|
2002-06-29 00:04:16 +00:00
|
|
|
// do not instantiate
|
|
|
|
IndicReordering();
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
static le_int32 findSyllable(const IndicClassTable *classTable, const LEUnicode *chars, le_int32 prev, le_int32 charCount);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
inline le_int32 IndicClassTable::getWorstCaseExpansion() const
|
|
|
|
{
|
|
|
|
return worstCaseExpansion;
|
|
|
|
}
|
|
|
|
|
2005-09-02 18:22:09 +00:00
|
|
|
inline le_bool IndicClassTable::getFilterZeroWidth() const
|
|
|
|
{
|
|
|
|
return (scriptFlags & SF_FILTER_ZERO_WIDTH) != 0;
|
|
|
|
}
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
inline const SplitMatra *IndicClassTable::getSplitMatra(CharClass charClass) const
|
|
|
|
{
|
|
|
|
le_int32 index = (charClass & CF_INDEX_MASK) >> CF_INDEX_SHIFT;
|
|
|
|
|
|
|
|
return &splitMatraTable[index - 1];
|
|
|
|
}
|
|
|
|
|
2004-02-13 19:34:17 +00:00
|
|
|
inline le_bool IndicClassTable::isVowelModifier(CharClass charClass)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2004-02-13 19:34:17 +00:00
|
|
|
return (charClass & CF_CLASS_MASK) == CC_VOWEL_MODIFIER;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2004-02-13 19:34:17 +00:00
|
|
|
inline le_bool IndicClassTable::isStressMark(CharClass charClass)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2004-02-13 19:34:17 +00:00
|
|
|
return (charClass & CF_CLASS_MASK) == CC_STRESS_MARK;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::isConsonant(CharClass charClass)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return (charClass & CF_CONSONANT) != 0;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::isReph(CharClass charClass)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return (charClass & CF_REPH) != 0;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::isNukta(CharClass charClass)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return (charClass & CF_CLASS_MASK) == CC_NUKTA;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::isVirama(CharClass charClass)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return (charClass & CF_CLASS_MASK) == CC_VIRAMA;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2008-05-27 22:44:40 +00:00
|
|
|
inline le_bool IndicClassTable::isAlLakuna(CharClass charClass)
|
|
|
|
{
|
|
|
|
return (charClass & CF_CLASS_MASK) == CC_AL_LAKUNA;
|
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::isVattu(CharClass charClass)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return (charClass & CF_VATTU) != 0;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::isMatra(CharClass charClass)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2004-08-24 22:42:42 +00:00
|
|
|
charClass &= CF_CLASS_MASK;
|
|
|
|
|
|
|
|
return charClass >= CC_DEPENDENT_VOWEL && charClass <= CC_SPLIT_VOWEL_PIECE_3;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::isSplitMatra(CharClass charClass)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return (charClass & CF_INDEX_MASK) != 0;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::isLengthMark(CharClass charClass)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return (charClass & CF_LENGTH_MARK) != 0;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::hasPostOrBelowBaseForm(CharClass charClass)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return (charClass & (CF_POST_BASE | CF_BELOW_BASE)) != 0;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::hasPostBaseForm(CharClass charClass)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return (charClass & CF_POST_BASE) != 0;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::hasBelowBaseForm(CharClass charClass)
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return (charClass & CF_BELOW_BASE) != 0;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2004-02-13 19:34:17 +00:00
|
|
|
inline le_bool IndicClassTable::isVowelModifier(LEUnicode ch) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2004-02-13 19:34:17 +00:00
|
|
|
return isVowelModifier(getCharClass(ch));
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2004-02-13 19:34:17 +00:00
|
|
|
inline le_bool IndicClassTable::isStressMark(LEUnicode ch) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2004-02-13 19:34:17 +00:00
|
|
|
return isStressMark(getCharClass(ch));
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::isConsonant(LEUnicode ch) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return isConsonant(getCharClass(ch));
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::isReph(LEUnicode ch) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return isReph(getCharClass(ch));
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::isVirama(LEUnicode ch) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return isVirama(getCharClass(ch));
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2008-05-27 22:44:40 +00:00
|
|
|
inline le_bool IndicClassTable::isAlLakuna(LEUnicode ch) const
|
|
|
|
{
|
|
|
|
return isAlLakuna(getCharClass(ch));
|
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::isNukta(LEUnicode ch) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return isNukta(getCharClass(ch));
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::isVattu(LEUnicode ch) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return isVattu(getCharClass(ch));
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::isMatra(LEUnicode ch) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return isMatra(getCharClass(ch));
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::isSplitMatra(LEUnicode ch) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return isSplitMatra(getCharClass(ch));
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::isLengthMark(LEUnicode ch) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return isLengthMark(getCharClass(ch));
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::hasPostOrBelowBaseForm(LEUnicode ch) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return hasPostOrBelowBaseForm(getCharClass(ch));
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::hasPostBaseForm(LEUnicode ch) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return hasPostBaseForm(getCharClass(ch));
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2003-05-22 21:56:57 +00:00
|
|
|
inline le_bool IndicClassTable::hasBelowBaseForm(LEUnicode ch) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-05-22 21:56:57 +00:00
|
|
|
return hasBelowBaseForm(getCharClass(ch));
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2001-10-16 00:39:01 +00:00
|
|
|
U_NAMESPACE_END
|
2000-11-28 20:56:52 +00:00
|
|
|
#endif
|