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