2
|
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
|
5506
|
6 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
7 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
8 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
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 |
*
|
5506
|
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.
|
2
|
23 |
*
|
|
24 |
*/
|
|
25 |
|
|
26 |
/*
|
|
27 |
*
|
16889
|
28 |
* (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
|
2
|
29 |
*
|
|
30 |
*/
|
|
31 |
|
|
32 |
#ifndef __STATETABLES_H
|
|
33 |
#define __STATETABLES_H
|
|
34 |
|
3935
|
35 |
/**
|
|
36 |
* \file
|
|
37 |
* \internal
|
|
38 |
*/
|
|
39 |
|
2
|
40 |
#include "LETypes.h"
|
|
41 |
#include "LayoutTables.h"
|
|
42 |
|
3935
|
43 |
U_NAMESPACE_BEGIN
|
|
44 |
|
16890
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
/*
|
|
49 |
* State table loop detection.
|
|
50 |
* Detects if too many ( LE_STATE_PATIENCE_COUNT ) state changes occur without moving the glyph index 'g'.
|
|
51 |
*
|
|
52 |
* Usage (pseudocode):
|
|
53 |
*
|
|
54 |
* {
|
|
55 |
* LE_STATE_PATIENCE_INIT();
|
|
56 |
*
|
|
57 |
* int g=0; // the glyph index - expect it to be moving
|
|
58 |
*
|
|
59 |
* for(;;) {
|
|
60 |
* if(LE_STATE_PATIENCE_DECR()) { // decrements the patience counter
|
|
61 |
* // ran out of patience, get out.
|
|
62 |
* break;
|
|
63 |
* }
|
|
64 |
*
|
|
65 |
* LE_STATE_PATIENCE_CURR(int, g); // store the 'current'
|
|
66 |
* state = newState(state,g);
|
|
67 |
* g+= <something, could be zero>;
|
|
68 |
* LE_STATE_PATIENCE_INCR(g); // if g has moved, increment the patience counter. Otherwise leave it.
|
|
69 |
* }
|
|
70 |
*
|
|
71 |
*/
|
|
72 |
|
|
73 |
#define LE_STATE_PATIENCE_COUNT 4096 /**< give up if a state table doesn't move the glyph after this many iterations */
|
|
74 |
#define LE_STATE_PATIENCE_INIT() le_uint32 le_patience_count = LE_STATE_PATIENCE_COUNT
|
|
75 |
#define LE_STATE_PATIENCE_DECR() --le_patience_count==0
|
|
76 |
#define LE_STATE_PATIENCE_CURR(type,x) type le_patience_curr=(x)
|
|
77 |
#define LE_STATE_PATIENCE_INCR(x) if((x)!=le_patience_curr) ++le_patience_count;
|
|
78 |
|
|
79 |
|
2
|
80 |
struct StateTableHeader
|
|
81 |
{
|
|
82 |
le_int16 stateSize;
|
|
83 |
ByteOffset classTableOffset;
|
|
84 |
ByteOffset stateArrayOffset;
|
|
85 |
ByteOffset entryTableOffset;
|
|
86 |
};
|
|
87 |
|
16889
|
88 |
struct StateTableHeader2
|
|
89 |
{
|
|
90 |
le_uint32 nClasses;
|
|
91 |
le_uint32 classTableOffset;
|
|
92 |
le_uint32 stateArrayOffset;
|
|
93 |
le_uint32 entryTableOffset;
|
|
94 |
};
|
|
95 |
|
2
|
96 |
enum ClassCodes
|
|
97 |
{
|
|
98 |
classCodeEOT = 0,
|
|
99 |
classCodeOOB = 1,
|
|
100 |
classCodeDEL = 2,
|
|
101 |
classCodeEOL = 3,
|
|
102 |
classCodeFirstFree = 4,
|
|
103 |
classCodeMAX = 0xFF
|
|
104 |
};
|
|
105 |
|
|
106 |
typedef le_uint8 ClassCode;
|
|
107 |
|
|
108 |
struct ClassTable
|
|
109 |
{
|
|
110 |
TTGlyphID firstGlyph;
|
|
111 |
le_uint16 nGlyphs;
|
|
112 |
ClassCode classArray[ANY_NUMBER];
|
|
113 |
};
|
16891
|
114 |
LE_VAR_ARRAY(ClassTable, classArray)
|
2
|
115 |
|
|
116 |
enum StateNumber
|
|
117 |
{
|
|
118 |
stateSOT = 0,
|
|
119 |
stateSOL = 1,
|
|
120 |
stateFirstFree = 2,
|
|
121 |
stateMAX = 0xFF
|
|
122 |
};
|
|
123 |
|
|
124 |
typedef le_uint8 EntryTableIndex;
|
|
125 |
|
|
126 |
struct StateEntry
|
|
127 |
{
|
|
128 |
ByteOffset newStateOffset;
|
|
129 |
le_int16 flags;
|
|
130 |
};
|
|
131 |
|
16889
|
132 |
typedef le_uint16 EntryTableIndex2;
|
|
133 |
|
|
134 |
struct StateEntry2 // same struct different interpretation
|
|
135 |
{
|
|
136 |
le_uint16 newStateIndex;
|
|
137 |
le_uint16 flags;
|
|
138 |
};
|
|
139 |
|
3935
|
140 |
U_NAMESPACE_END
|
2
|
141 |
#endif
|
3935
|
142 |
|