Home | History | Annotate | Download | only in layout
      1 /*
      2  *
      3  * (C) Copyright IBM Corp. and others 1998-2013 - All Rights Reserved
      4  *
      5  */
      6 
      7 #ifndef __STATETABLES_H
      8 #define __STATETABLES_H
      9 
     10 /**
     11  * \file
     12  * \internal
     13  */
     14 
     15 #include "LETypes.h"
     16 #include "LayoutTables.h"
     17 
     18 U_NAMESPACE_BEGIN
     19 
     20 
     21 
     22 
     23 /*
     24  * State table loop detection.
     25  * Detects if too many ( LE_STATE_PATIENCE_COUNT ) state changes occur without moving the glyph index 'g'.
     26  *
     27  * Usage (pseudocode):
     28  *
     29  * {
     30  *   LE_STATE_PATIENCE_INIT();
     31  *
     32  *   int g=0; // the glyph index - expect it to be moving
     33  *
     34  *   for(;;) {
     35  *     if(LE_STATE_PATIENCE_DECR()) { // decrements the patience counter
     36  *        // ran out of patience, get out.
     37  *        break;
     38  *     }
     39  *
     40  *     LE_STATE_PATIENCE_CURR(int, g); // store the 'current'
     41  *     state = newState(state,g);
     42  *     g+= <something, could be zero>;
     43  *     LE_STATE_PATIENCE_INCR(g);  // if g has moved, increment the patience counter. Otherwise leave it.
     44  *   }
     45  *
     46  */
     47 
     48 #define LE_STATE_PATIENCE_COUNT 4096 /**< give up if a state table doesn't move the glyph after this many iterations */
     49 #define LE_STATE_PATIENCE_INIT()  le_uint32 le_patience_count = LE_STATE_PATIENCE_COUNT
     50 #define LE_STATE_PATIENCE_DECR()  --le_patience_count==0
     51 #define LE_STATE_PATIENCE_CURR(type,x)  type le_patience_curr=(x)
     52 #define LE_STATE_PATIENCE_INCR(x)    if((x)!=le_patience_curr) ++le_patience_count;
     53 
     54 
     55 struct StateTableHeader
     56 {
     57     le_int16 stateSize;
     58     ByteOffset classTableOffset;
     59     ByteOffset stateArrayOffset;
     60     ByteOffset entryTableOffset;
     61 };
     62 
     63 struct StateTableHeader2
     64 {
     65     le_uint32 nClasses;
     66     le_uint32 classTableOffset;
     67     le_uint32 stateArrayOffset;
     68     le_uint32 entryTableOffset;
     69 };
     70 
     71 enum ClassCodes
     72 {
     73     classCodeEOT = 0,
     74     classCodeOOB = 1,
     75     classCodeDEL = 2,
     76     classCodeEOL = 3,
     77     classCodeFirstFree = 4,
     78     classCodeMAX = 0xFF
     79 };
     80 
     81 typedef le_uint8 ClassCode;
     82 
     83 struct ClassTable
     84 {
     85     TTGlyphID firstGlyph;
     86     le_uint16 nGlyphs;
     87     ClassCode classArray[ANY_NUMBER];
     88 };
     89 LE_VAR_ARRAY(ClassTable, classArray)
     90 
     91 enum StateNumber
     92 {
     93     stateSOT        = 0,
     94     stateSOL        = 1,
     95     stateFirstFree  = 2,
     96     stateMAX        = 0xFF
     97 };
     98 
     99 typedef le_uint8 EntryTableIndex;
    100 
    101 struct StateEntry
    102 {
    103     ByteOffset  newStateOffset;
    104     le_int16    flags;
    105 };
    106 
    107 typedef le_uint16 EntryTableIndex2;
    108 
    109 struct StateEntry2 // same struct different interpretation
    110 {
    111     le_uint16    newStateIndex;
    112     le_uint16    flags;
    113 };
    114 
    115 U_NAMESPACE_END
    116 #endif
    117 
    118