]> git.saurik.com Git - apple/icu.git/blob - icuSources/layout/ThaiShaping.h
ICU-6.2.22.tar.gz
[apple/icu.git] / icuSources / layout / ThaiShaping.h
1 /*
2 *
3 * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
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
21 class LEGlyphStorage;
22
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
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
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,
71 LEUnicode errorChar, LEUnicode *output, LEGlyphStorage &glyphStorage);
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,
82 LEUnicode errorChar, LEUnicode *outputBuffer, LEGlyphStorage &glyphStorage, le_int32 &outputIndex);
83
84 static le_uint8 getNextState(LEUnicode ch, le_uint8 state, le_int32 inputIndex, le_uint8 glyphSet, LEUnicode errorChar,
85 le_uint8 &charClass, LEUnicode *output, LEGlyphStorage &glyphStorage, le_int32 &outputIndex);
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