1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation. Oracle designates this
7 * particular file as subject to the "Classpath" exception as provided
8 * by Oracle in the LICENSE file that accompanied this code.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 /*
27 *
28 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
29 *
30 */
31
32 #ifndef __THAISHAPING_H
33 #define __THAISHAPING_H
34
35 /**
36 * \file
37 * \internal
38 */
39
40 #include "LETypes.h"
41 #include "LEGlyphFilter.h"
42 #include "OpenTypeTables.h"
43
44 U_NAMESPACE_BEGIN
45
46 class LEGlyphStorage;
47
48 class ThaiShaping /* not : public UObject because all methods are static */ {
49 public:
50
51 enum {
52 // Character classes
53 NON = 0,
54 CON = 1,
55 COA = 2,
56 COD = 3,
57 LVO = 4,
58 FV1 = 5,
59 FV2 = 6,
60 FV3 = 7,
61 BV1 = 8,
62 BV2 = 9,
63 BDI = 10,
64 TON = 11,
65 AD1 = 12,
66 AD2 = 13,
67 AD3 = 14,
68 NIK = 15,
69 AV1 = 16,
70 AV2 = 17,
71 AV3 = 18,
72 classCount = 19,
73
74 // State Transition actions
75 tA = 0,
76 tC = 1,
77 tD = 2,
78 tE = 3,
79 tF = 4,
80 tG = 5,
81 tH = 6,
82 tR = 7,
83 tS = 8
84 };
85
86 struct StateTransition
87 {
88 le_uint8 nextState;
89 le_uint8 action;
90
getNextStateStateTransition91 le_uint8 getNextState() { return nextState; };
getActionStateTransition92 le_uint8 getAction() { return action; };
93 };
94
95 static le_int32 compose(const LEUnicode *input, le_int32 offset, le_int32 charCount, le_uint8 glyphSet,
96 LEUnicode errorChar, LEUnicode *output, LEGlyphStorage &glyphStorage);
97
98 private:
99 // forbid instantiation
100 ThaiShaping();
101
102 static const le_uint8 classTable[];
103 static const StateTransition thaiStateTable[][classCount];
104
105 inline static StateTransition getTransition(le_uint8 state, le_uint8 currClass);
106
107 static le_uint8 doTransition(StateTransition transition, LEUnicode currChar, le_int32 inputIndex, le_uint8 glyphSet,
108 LEUnicode errorChar, LEUnicode *outputBuffer, LEGlyphStorage &glyphStorage, le_int32 &outputIndex);
109
110 static le_uint8 getNextState(LEUnicode ch, le_uint8 state, le_int32 inputIndex, le_uint8 glyphSet, LEUnicode errorChar,
111 le_uint8 &charClass, LEUnicode *output, LEGlyphStorage &glyphStorage, le_int32 &outputIndex);
112
113 static le_bool isLegalHere(LEUnicode ch, le_uint8 prevState);
114 static le_uint8 getCharClass(LEUnicode ch);
115
116 static LEUnicode noDescenderCOD(LEUnicode cod, le_uint8 glyphSet);
117 static LEUnicode leftAboveVowel(LEUnicode vowel, le_uint8 glyphSet);
118 static LEUnicode lowerBelowVowel(LEUnicode vowel, le_uint8 glyphSet);
119 static LEUnicode lowerRightTone(LEUnicode tone, le_uint8 glyphSet);
120 static LEUnicode lowerLeftTone(LEUnicode tone, le_uint8 glyphSet);
121 static LEUnicode upperLeftTone(LEUnicode tone, le_uint8 glyphSet);
122
123 };
124
getTransition(le_uint8 state,le_uint8 currClass)125 inline ThaiShaping::StateTransition ThaiShaping::getTransition(le_uint8 state, le_uint8 currClass)
126 {
127 return thaiStateTable[state][currClass];
128 }
129
130 U_NAMESPACE_END
131 #endif
132
133
134