]>
Commit | Line | Data |
---|---|---|
b75a7d8f | 1 | /* |
b75a7d8f | 2 | * |
374ca955 | 3 | * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved |
b75a7d8f A |
4 | * |
5 | */ | |
6 | ||
7 | #ifndef __THAISHAPING_H | |
8 | #define __THAISHAPING_H | |
9 | ||
10 | /** | |
11 | * \file | |
12 | * \internal | |
13 | */ | |
14 | ||
15 | #include "LETypes.h" | |
16 | #include "LEGlyphFilter.h" | |
17 | #include "OpenTypeTables.h" | |
18 | ||
19 | U_NAMESPACE_BEGIN | |
20 | ||
374ca955 A |
21 | class LEGlyphStorage; |
22 | ||
b75a7d8f A |
23 | class ThaiShaping /* not : public UObject because all methods are static */ { |
24 | public: | |
25 | ||
26 | enum { | |
27 | // Character classes | |
28 | NON = 0, | |
29 | CON = 1, | |
30 | COA = 2, | |
31 | COD = 3, | |
32 | LVO = 4, | |
33 | FV1 = 5, | |
34 | FV2 = 6, | |
35 | FV3 = 7, | |
36 | BV1 = 8, | |
37 | BV2 = 9, | |
38 | BDI = 10, | |
39 | TON = 11, | |
40 | AD1 = 12, | |
41 | AD2 = 13, | |
42 | AD3 = 14, | |
43 | NIK = 15, | |
44 | AV1 = 16, | |
45 | AV2 = 17, | |
46 | AV3 = 18, | |
47 | classCount = 19, | |
48 | ||
49 | // State Transition actions | |
374ca955 A |
50 | tA = 0, |
51 | tC = 1, | |
52 | tD = 2, | |
53 | tE = 3, | |
54 | tF = 4, | |
55 | tG = 5, | |
56 | tH = 6, | |
57 | tR = 7, | |
58 | tS = 8 | |
b75a7d8f A |
59 | }; |
60 | ||
61 | struct StateTransition | |
62 | { | |
63 | le_uint8 nextState; | |
64 | le_uint8 action; | |
65 | ||
66 | le_uint8 getNextState() { return nextState; }; | |
67 | le_uint8 getAction() { return action; }; | |
68 | }; | |
69 | ||
70 | static le_int32 compose(const LEUnicode *input, le_int32 offset, le_int32 charCount, le_uint8 glyphSet, | |
374ca955 | 71 | LEUnicode errorChar, LEUnicode *output, LEGlyphStorage &glyphStorage); |
b75a7d8f A |
72 | |
73 | private: | |
74 | // forbid instantiation | |
75 | ThaiShaping(); | |
76 | ||
77 | static const le_uint8 classTable[]; | |
78 | static const StateTransition thaiStateTable[][classCount]; | |
79 | ||
80 | static StateTransition getTransition(le_uint8 state, le_uint8 currClass); | |
81 | static le_uint8 doTransition(StateTransition transition, LEUnicode currChar, le_int32 inputIndex, le_uint8 glyphSet, | |
374ca955 | 82 | LEUnicode errorChar, LEUnicode *outputBuffer, LEGlyphStorage &glyphStorage, le_int32 &outputIndex); |
b75a7d8f A |
83 | |
84 | static le_uint8 getNextState(LEUnicode ch, le_uint8 state, le_int32 inputIndex, le_uint8 glyphSet, LEUnicode errorChar, | |
374ca955 | 85 | le_uint8 &charClass, LEUnicode *output, LEGlyphStorage &glyphStorage, le_int32 &outputIndex); |
b75a7d8f A |
86 | |
87 | static le_bool isLegalHere(LEUnicode ch, le_uint8 prevState); | |
88 | static le_uint8 getCharClass(LEUnicode ch); | |
89 | ||
90 | static LEUnicode noDescenderCOD(LEUnicode cod, le_uint8 glyphSet); | |
91 | static LEUnicode leftAboveVowel(LEUnicode vowel, le_uint8 glyphSet); | |
92 | static LEUnicode lowerBelowVowel(LEUnicode vowel, le_uint8 glyphSet); | |
93 | static LEUnicode lowerRightTone(LEUnicode tone, le_uint8 glyphSet); | |
94 | static LEUnicode lowerLeftTone(LEUnicode tone, le_uint8 glyphSet); | |
95 | static LEUnicode upperLeftTone(LEUnicode tone, le_uint8 glyphSet); | |
96 | ||
97 | }; | |
98 | ||
99 | inline ThaiShaping::StateTransition ThaiShaping::getTransition(le_uint8 state, le_uint8 currClass) | |
100 | { | |
101 | return thaiStateTable[state][currClass]; | |
102 | } | |
103 | ||
104 | U_NAMESPACE_END | |
105 | #endif | |
106 | ||
107 |