3 * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
7 #ifndef __INDICREORDERING_H
8 #define __INDICREORDERING_H
16 #include "OpenTypeTables.h"
20 // Characters that get refered to by name...
27 typedef LEUnicode SplitMatra
[3];
32 struct IndicClassTable
37 CC_VOWEL_MODIFIER
= 1,
39 CC_INDEPENDENT_VOWEL
= 3,
40 CC_INDEPENDENT_VOWEL_2
= 4,
42 CC_CONSONANT_WITH_NUKTA
= 6,
44 CC_DEPENDENT_VOWEL
= 8,
45 CC_SPLIT_VOWEL_PIECE_1
= 9,
46 CC_SPLIT_VOWEL_PIECE_2
= 10,
47 CC_SPLIT_VOWEL_PIECE_3
= 11,
49 CC_ZERO_WIDTH_MARK
= 13,
55 CF_CLASS_MASK
= 0x0000FFFF,
57 CF_CONSONANT
= 0x80000000,
60 CF_VATTU
= 0x20000000,
61 CF_BELOW_BASE
= 0x10000000,
62 CF_POST_BASE
= 0x08000000,
63 CF_LENGTH_MARK
= 0x04000000,
65 CF_POS_BEFORE
= 0x00300000,
66 CF_POS_BELOW
= 0x00200000,
67 CF_POS_ABOVE
= 0x00100000,
68 CF_POS_AFTER
= 0x00000000,
69 CF_POS_MASK
= 0x00300000,
71 CF_INDEX_MASK
= 0x000F0000,
75 typedef le_uint32 CharClass
;
79 SF_MATRAS_AFTER_BASE
= 0x80000000,
80 SF_REPH_AFTER_BELOW
= 0x40000000,
81 SF_EYELASH_RA
= 0x20000000,
82 SF_MPRE_FIXUP
= 0x10000000,
84 SF_POST_BASE_LIMIT_MASK
= 0x0000FFFF,
85 SF_NO_POST_BASE_LIMIT
= 0x00007FFF
88 typedef le_int32 ScriptFlags
;
92 le_int32 worstCaseExpansion
;
93 ScriptFlags scriptFlags
;
94 const CharClass
*classTable
;
95 const SplitMatra
*splitMatraTable
;
97 le_int32
getWorstCaseExpansion() const;
99 CharClass
getCharClass(LEUnicode ch
) const;
100 const SplitMatra
*getSplitMatra(CharClass charClass
) const;
102 le_bool
isVowelModifier(LEUnicode ch
) const;
103 le_bool
isStressMark(LEUnicode ch
) const;
104 le_bool
isConsonant(LEUnicode ch
) const;
105 le_bool
isReph(LEUnicode ch
) const;
106 le_bool
isVirama(LEUnicode ch
) const;
107 le_bool
isNukta(LEUnicode ch
) const;
108 le_bool
isVattu(LEUnicode ch
) const;
109 le_bool
isMatra(LEUnicode ch
) const;
110 le_bool
isSplitMatra(LEUnicode ch
) const;
111 le_bool
isLengthMark(LEUnicode ch
) const;
112 le_bool
hasPostOrBelowBaseForm(LEUnicode ch
) const;
113 le_bool
hasPostBaseForm(LEUnicode ch
) const;
114 le_bool
hasBelowBaseForm(LEUnicode ch
) const;
116 static le_bool
isVowelModifier(CharClass charClass
);
117 static le_bool
isStressMark(CharClass charClass
);
118 static le_bool
isConsonant(CharClass charClass
);
119 static le_bool
isReph(CharClass charClass
);
120 static le_bool
isVirama(CharClass charClass
);
121 static le_bool
isNukta(CharClass charClass
);
122 static le_bool
isVattu(CharClass charClass
);
123 static le_bool
isMatra(CharClass charClass
);
124 static le_bool
isSplitMatra(CharClass charClass
);
125 static le_bool
isLengthMark(CharClass charClass
);
126 static le_bool
hasPostOrBelowBaseForm(CharClass charClass
);
127 static le_bool
hasPostBaseForm(CharClass charClass
);
128 static le_bool
hasBelowBaseForm(CharClass charClass
);
130 static const IndicClassTable
*getScriptClassTable(le_int32 scriptCode
);
133 class IndicReordering
/* not : public UObject because all methods are static */ {
135 static le_int32
getWorstCaseExpansion(le_int32 scriptCode
);
137 static le_int32
reorder(const LEUnicode
*theChars
, le_int32 charCount
, le_int32 scriptCode
,
138 LEUnicode
*outChars
, LEGlyphStorage
&glyphStorage
,
139 MPreFixups
**outMPreFixups
);
141 static void adjustMPres(MPreFixups
*mpreFixups
, LEGlyphStorage
&glyphStorage
);
143 static const LETag
*getFeatureOrder();
146 // do not instantiate
149 static le_int32
findSyllable(const IndicClassTable
*classTable
, const LEUnicode
*chars
, le_int32 prev
, le_int32 charCount
);
153 inline le_int32
IndicClassTable::getWorstCaseExpansion() const
155 return worstCaseExpansion
;
158 inline const SplitMatra
*IndicClassTable::getSplitMatra(CharClass charClass
) const
160 le_int32 index
= (charClass
& CF_INDEX_MASK
) >> CF_INDEX_SHIFT
;
162 return &splitMatraTable
[index
- 1];
165 inline le_bool
IndicClassTable::isVowelModifier(CharClass charClass
)
167 return (charClass
& CF_CLASS_MASK
) == CC_VOWEL_MODIFIER
;
170 inline le_bool
IndicClassTable::isStressMark(CharClass charClass
)
172 return (charClass
& CF_CLASS_MASK
) == CC_STRESS_MARK
;
175 inline le_bool
IndicClassTable::isConsonant(CharClass charClass
)
177 return (charClass
& CF_CONSONANT
) != 0;
180 inline le_bool
IndicClassTable::isReph(CharClass charClass
)
182 return (charClass
& CF_REPH
) != 0;
185 inline le_bool
IndicClassTable::isNukta(CharClass charClass
)
187 return (charClass
& CF_CLASS_MASK
) == CC_NUKTA
;
190 inline le_bool
IndicClassTable::isVirama(CharClass charClass
)
192 return (charClass
& CF_CLASS_MASK
) == CC_VIRAMA
;
195 inline le_bool
IndicClassTable::isVattu(CharClass charClass
)
197 return (charClass
& CF_VATTU
) != 0;
200 inline le_bool
IndicClassTable::isMatra(CharClass charClass
)
202 charClass
&= CF_CLASS_MASK
;
204 return charClass
>= CC_DEPENDENT_VOWEL
&& charClass
<= CC_SPLIT_VOWEL_PIECE_3
;
207 inline le_bool
IndicClassTable::isSplitMatra(CharClass charClass
)
209 return (charClass
& CF_INDEX_MASK
) != 0;
212 inline le_bool
IndicClassTable::isLengthMark(CharClass charClass
)
214 return (charClass
& CF_LENGTH_MARK
) != 0;
217 inline le_bool
IndicClassTable::hasPostOrBelowBaseForm(CharClass charClass
)
219 return (charClass
& (CF_POST_BASE
| CF_BELOW_BASE
)) != 0;
222 inline le_bool
IndicClassTable::hasPostBaseForm(CharClass charClass
)
224 return (charClass
& CF_POST_BASE
) != 0;
227 inline le_bool
IndicClassTable::hasBelowBaseForm(CharClass charClass
)
229 return (charClass
& CF_BELOW_BASE
) != 0;
232 inline le_bool
IndicClassTable::isVowelModifier(LEUnicode ch
) const
234 return isVowelModifier(getCharClass(ch
));
237 inline le_bool
IndicClassTable::isStressMark(LEUnicode ch
) const
239 return isStressMark(getCharClass(ch
));
242 inline le_bool
IndicClassTable::isConsonant(LEUnicode ch
) const
244 return isConsonant(getCharClass(ch
));
247 inline le_bool
IndicClassTable::isReph(LEUnicode ch
) const
249 return isReph(getCharClass(ch
));
252 inline le_bool
IndicClassTable::isVirama(LEUnicode ch
) const
254 return isVirama(getCharClass(ch
));
257 inline le_bool
IndicClassTable::isNukta(LEUnicode ch
) const
259 return isNukta(getCharClass(ch
));
262 inline le_bool
IndicClassTable::isVattu(LEUnicode ch
) const
264 return isVattu(getCharClass(ch
));
267 inline le_bool
IndicClassTable::isMatra(LEUnicode ch
) const
269 return isMatra(getCharClass(ch
));
272 inline le_bool
IndicClassTable::isSplitMatra(LEUnicode ch
) const
274 return isSplitMatra(getCharClass(ch
));
277 inline le_bool
IndicClassTable::isLengthMark(LEUnicode ch
) const
279 return isLengthMark(getCharClass(ch
));
282 inline le_bool
IndicClassTable::hasPostOrBelowBaseForm(LEUnicode ch
) const
284 return hasPostOrBelowBaseForm(getCharClass(ch
));
287 inline le_bool
IndicClassTable::hasPostBaseForm(LEUnicode ch
) const
289 return hasPostBaseForm(getCharClass(ch
));
292 inline le_bool
IndicClassTable::hasBelowBaseForm(LEUnicode ch
) const
294 return hasBelowBaseForm(getCharClass(ch
));