Home | History | Annotate | Download | only in layout
      1 /*
      2  *
      3  * (C) Copyright IBM Corp. 1998-2005 - 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     inline static StateTransition getTransition(le_uint8 state, le_uint8 currClass);
     81 
     82     static le_uint8 doTransition(StateTransition transition, LEUnicode currChar, le_int32 inputIndex, le_uint8 glyphSet,
     83         LEUnicode errorChar, LEUnicode *outputBuffer, LEGlyphStorage &glyphStorage, le_int32 &outputIndex);
     84 
     85     static le_uint8 getNextState(LEUnicode ch, le_uint8 state, le_int32 inputIndex, le_uint8 glyphSet, LEUnicode errorChar,
     86         le_uint8 &charClass, LEUnicode *output, LEGlyphStorage &glyphStorage, le_int32 &outputIndex);
     87 
     88     static le_bool isLegalHere(LEUnicode ch, le_uint8 prevState);
     89     static le_uint8 getCharClass(LEUnicode ch);
     90 
     91     static LEUnicode noDescenderCOD(LEUnicode cod, le_uint8 glyphSet);
     92     static LEUnicode leftAboveVowel(LEUnicode vowel, le_uint8 glyphSet);
     93     static LEUnicode lowerBelowVowel(LEUnicode vowel, le_uint8 glyphSet);
     94     static LEUnicode lowerRightTone(LEUnicode tone, le_uint8 glyphSet);
     95     static LEUnicode lowerLeftTone(LEUnicode tone, le_uint8 glyphSet);
     96     static LEUnicode upperLeftTone(LEUnicode tone, le_uint8 glyphSet);
     97 
     98 };
     99 
    100 inline ThaiShaping::StateTransition ThaiShaping::getTransition(le_uint8 state, le_uint8 currClass)
    101 {
    102     return thaiStateTable[state][currClass];
    103 }
    104 
    105 U_NAMESPACE_END
    106 #endif
    107 
    108 
    109