summaryrefslogtreecommitdiff
path: root/Build/source/libs/icu/icu-4.2.1-PATCHES/patch-05-auxParam
blob: c68d525e3e3ae9cfd75db1181fefcd3fb942a209 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
diff -ur icu-4.2.1.orig/source/layout/AlternateSubstSubtables.cpp icu-4.2.1/source/layout/AlternateSubstSubtables.cpp
--- icu-4.2.1.orig/source/layout/AlternateSubstSubtables.cpp	2009-07-01 20:51:24.000000000 +0200
+++ icu-4.2.1/source/layout/AlternateSubstSubtables.cpp	2009-10-23 00:00:56.000000000 +0200
@@ -27,13 +27,20 @@
             Offset alternateSetTableOffset = SWAPW(alternateSetTableOffsetArray[coverageIndex]);
             const AlternateSetTable *alternateSetTable =
                 (const AlternateSetTable *) ((char *) this + alternateSetTableOffset);
-            TTGlyphID alternate = SWAPW(alternateSetTable->alternateArray[0]);
+			le_int32 altIndex = glyphIterator->getFeatureParam();
 
-            if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, alternate))) {
-                glyphIterator->setCurrGlyphID(SWAPW(alternateSetTable->alternateArray[0]));
+			if (altIndex < SWAPW(alternateSetTable->glyphCount)) {
+	            TTGlyphID alternate = SWAPW(alternateSetTable->alternateArray[altIndex]);
+
+	            if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, alternate))) {
+    	            glyphIterator->setCurrGlyphID(alternate);
+        	    }
+
+	            return 1;
             }
-            
-            return 1;
+
+			// feature param was out of range for the glyph
+            return 0;
         }
 
         // XXXX If we get here, the table's mal-formed...
diff -ur icu-4.2.1.orig/source/layout/GlyphIterator.cpp icu-4.2.1/source/layout/GlyphIterator.cpp
--- icu-4.2.1.orig/source/layout/GlyphIterator.cpp	2009-07-01 20:51:24.000000000 +0200
+++ icu-4.2.1/source/layout/GlyphIterator.cpp	2009-10-23 00:00:56.000000000 +0200
@@ -19,7 +19,7 @@
                              FeatureMask theFeatureMask, const GlyphDefinitionTableHeader *theGlyphDefinitionTableHeader)
   : direction(1), position(-1), nextLimit(-1), prevLimit(-1),
     glyphStorage(theGlyphStorage), glyphPositionAdjustments(theGlyphPositionAdjustments),
-    srcIndex(-1), destIndex(-1), lookupFlags(theLookupFlags), featureMask(theFeatureMask), glyphGroup(0),
+    srcIndex(-1), destIndex(-1), lookupFlags(theLookupFlags), featureMask(theFeatureMask), featureParam(0), glyphGroup(0),
     glyphClassDefinitionTable(NULL), markAttachClassDefinitionTable(NULL)
 
 {
@@ -53,12 +53,13 @@
     destIndex = that.destIndex;
     lookupFlags = that.lookupFlags;
     featureMask = that.featureMask;
+    featureParam = that.featureParam;
     glyphGroup  = that.glyphGroup;
     glyphClassDefinitionTable = that.glyphClassDefinitionTable;
     markAttachClassDefinitionTable = that.markAttachClassDefinitionTable;
 }
 
-GlyphIterator::GlyphIterator(GlyphIterator &that, FeatureMask newFeatureMask)
+GlyphIterator::GlyphIterator(GlyphIterator &that, FeatureMask newFeatureMask, le_int32 newFeatureParam)
   : glyphStorage(that.glyphStorage)
 {
     direction    = that.direction;
@@ -71,6 +72,7 @@
     destIndex = that.destIndex;
     lookupFlags = that.lookupFlags;
     featureMask = newFeatureMask;
+    featureParam = newFeatureParam;
     glyphGroup  = 0;
     glyphClassDefinitionTable = that.glyphClassDefinitionTable;
     markAttachClassDefinitionTable = that.markAttachClassDefinitionTable;
@@ -89,6 +91,7 @@
     destIndex = that.destIndex;
     lookupFlags = newLookupFlags;
     featureMask = that.featureMask;
+    featureParam = that.featureParam;
     glyphGroup  = that.glyphGroup;
     glyphClassDefinitionTable = that.glyphClassDefinitionTable;
     markAttachClassDefinitionTable = that.markAttachClassDefinitionTable;
@@ -103,6 +106,7 @@
 {
     position     = prevLimit;
     featureMask  = newFeatureMask;
+    featureParam = 0;
     glyphGroup   = 0;
     lookupFlags  = newLookupFlags;
 }
@@ -130,6 +134,11 @@
     return position;
 }
 
+le_int32 GlyphIterator::getFeatureParam() const
+{
+	return featureParam;
+}
+
 le_bool GlyphIterator::isRightToLeft() const
 {
     return direction < 0;
@@ -400,8 +409,10 @@
     }
 }
 
-le_bool GlyphIterator::hasFeatureTag(le_bool matchGroup) const
+le_bool GlyphIterator::hasFeatureTag(le_bool matchGroup)
 {
+    featureParam = 0;
+
     if (featureMask == 0) {
         return TRUE;
     }
@@ -409,7 +420,20 @@
     LEErrorCode success = LE_NO_ERROR;
     FeatureMask fm = glyphStorage.getAuxData(position, success);
 
-    return ((fm & featureMask) == featureMask) && (!matchGroup || (le_int32)(fm & LE_GLYPH_GROUP_MASK) == glyphGroup);
+    if (((fm & featureMask) == featureMask) && (!matchGroup || (le_int32)(fm & LE_GLYPH_GROUP_MASK) == glyphGroup)) {
+	const le_int32 *paramList = (const le_int32 *) glyphStorage.getAuxParam(position, success);
+        if (paramList != NULL) {
+            fm = featureMask;
+            while ((fm & 0x80000000UL) == 0) {
+            	++paramList;
+            	fm <<= 1;
+            }
+            featureParam = *paramList;
+        }
+        return TRUE;
+    }
+
+    return FALSE;
 }
 
 le_bool GlyphIterator::findFeatureTag()
diff -ur icu-4.2.1.orig/source/layout/GlyphIterator.h icu-4.2.1/source/layout/GlyphIterator.h
--- icu-4.2.1.orig/source/layout/GlyphIterator.h	2009-07-01 20:51:26.000000000 +0200
+++ icu-4.2.1/source/layout/GlyphIterator.h	2009-10-23 00:00:56.000000000 +0200
@@ -28,7 +28,7 @@
 
     GlyphIterator(GlyphIterator &that);
 
-    GlyphIterator(GlyphIterator &that, FeatureMask newFeatureMask);
+    GlyphIterator(GlyphIterator &that, FeatureMask newFeatureMask, le_int32 featureParam = 0);
 
     GlyphIterator(GlyphIterator &that, le_uint16 newLookupFlags);
 
@@ -51,6 +51,8 @@
     le_int32  getMarkComponent(le_int32 markPosition) const;
     le_bool   findMark2Glyph();
 
+    le_int32  getFeatureParam() const;
+
     void getCursiveEntryPoint(LEPoint &entryPoint) const;
     void getCursiveExitPoint(LEPoint &exitPoint) const;
 
@@ -74,7 +76,7 @@
 
 private:
     le_bool filterGlyph(le_uint32 index) const;
-    le_bool hasFeatureTag(le_bool matchGroup) const;
+    le_bool hasFeatureTag(le_bool matchGroup); /* not const because it updates the featureParam field */
     le_bool nextInternal(le_uint32 delta = 1);
     le_bool prevInternal(le_uint32 delta = 1);
 
@@ -92,6 +94,7 @@
     FeatureMask featureMask;
     le_int32    glyphGroup;
 
+    le_int32 featureParam;
     const GlyphClassDefinitionTable *glyphClassDefinitionTable;
     const MarkAttachClassDefinitionTable *markAttachClassDefinitionTable;
 
diff -ur icu-4.2.1.orig/source/layout/LEGlyphStorage.cpp icu-4.2.1/source/layout/LEGlyphStorage.cpp
--- icu-4.2.1.orig/source/layout/LEGlyphStorage.cpp	2009-07-01 20:51:26.000000000 +0200
+++ icu-4.2.1/source/layout/LEGlyphStorage.cpp	2009-10-23 00:00:56.000000000 +0200
@@ -20,7 +20,7 @@
 
 LEGlyphStorage::LEGlyphStorage()
     : fGlyphCount(0), fGlyphs(NULL), fCharIndices(NULL), fPositions(NULL),
-      fAuxData(NULL), fInsertionList(NULL), fSrcIndex(0), fDestIndex(0)
+      fAuxData(NULL), fAuxParam(NULL), fInsertionList(NULL), fSrcIndex(0), fDestIndex(0)
 {
     // nothing else to do!
 }
@@ -44,6 +44,11 @@
         fAuxData = NULL;
     }
 
+    if (fAuxParam != NULL) {
+        LE_DELETE_ARRAY(fAuxParam);
+        fAuxParam = NULL;
+    }
+
     if (fInsertionList != NULL) {
         delete fInsertionList;
         fInsertionList = NULL;
@@ -151,14 +156,15 @@
         return -1;
     }
 
-    if (fAuxData != NULL) {
+    if (fAuxData != NULL || fAuxParam != NULL) {
         success = LE_INTERNAL_ERROR;
         return -1;
     }
 
     fAuxData = LE_NEW_ARRAY(le_uint32, fGlyphCount);
+    fAuxParam = LE_NEW_ARRAY(void *, fGlyphCount);
 
-    if (fAuxData == NULL) {
+    if (fAuxData == NULL || fAuxParam == NULL) {
         success = LE_MEMORY_ALLOCATION_ERROR;
         return -1;
     }
@@ -365,13 +371,32 @@
     return fAuxData[glyphIndex];
 }
 
-void LEGlyphStorage::setAuxData(le_int32 glyphIndex, le_uint32 auxData, LEErrorCode &success)
+void *LEGlyphStorage::getAuxParam(le_int32 glyphIndex, LEErrorCode &success) const
+{
+    if (LE_FAILURE(success)) {
+        return NULL;
+    }
+
+    if (fAuxParam == NULL) {
+        success = LE_NO_LAYOUT_ERROR;
+        return NULL;
+    }
+    
+    if (glyphIndex < 0 || glyphIndex >= fGlyphCount) {
+        success = LE_INDEX_OUT_OF_BOUNDS_ERROR;
+        return NULL;
+    }
+
+    return fAuxParam[glyphIndex];
+}
+
+void LEGlyphStorage::setAuxData(le_int32 glyphIndex, le_uint32 auxData, void *auxParam, LEErrorCode &success)
 {
     if (LE_FAILURE(success)) {
         return;
     }
 
-    if (fAuxData == NULL) {
+    if (fAuxData == NULL || fAuxParam == NULL) {
         success = LE_NO_LAYOUT_ERROR;
         return;
     }
@@ -382,6 +407,7 @@
     }
 
     fAuxData[glyphIndex] = auxData;
+    fAuxParam[glyphIndex] = auxParam;
 }
 
 void LEGlyphStorage::getGlyphPositions(float positions[], LEErrorCode &success) const
@@ -496,8 +522,14 @@
         LE_DELETE_ARRAY(fAuxData);
     }
 
+    if (fAuxParam != NULL) {
+        LE_DELETE_ARRAY(fAuxParam);
+    }
+
     fAuxData = from.fAuxData;
     from.fAuxData = NULL;
+    fAuxParam = from.fAuxParam;
+    from.fAuxParam = NULL;
 }
 
 void LEGlyphStorage::adoptGlyphCount(LEGlyphStorage &from)
@@ -590,6 +622,10 @@
     fGlyphs = newGlyphs; 
     fCharIndices = newCharIndices;
 
+    if (fAuxParam != NULL) {
+        fAuxParam     = (void **) LE_GROW_ARRAY(fAuxParam,     newGlyphCount);
+    }
+
     fSrcIndex  = fGlyphCount - 1;
     fDestIndex = newGlyphCount - 1;
 
@@ -642,6 +678,18 @@
         }
     }
 
+    if (fAuxParam != NULL) {
+        le_int32 src = fSrcIndex, dest = fDestIndex;
+
+        while (src > atPosition) {
+            fAuxParam[dest--] = fAuxParam[src--];
+        }
+
+        for (le_int32 i = count - 1; i >= 0; i -= 1) {
+            fAuxParam[dest--] = fAuxParam[atPosition];
+        }
+    }
+
     while (fSrcIndex > atPosition) {
         fGlyphs[fDestIndex]      = fGlyphs[fSrcIndex];
         fCharIndices[fDestIndex] = fCharIndices[fSrcIndex];
diff -ur icu-4.2.1.orig/source/layout/LEGlyphStorage.h icu-4.2.1/source/layout/LEGlyphStorage.h
--- icu-4.2.1.orig/source/layout/LEGlyphStorage.h	2009-07-01 20:51:24.000000000 +0200
+++ icu-4.2.1/source/layout/LEGlyphStorage.h	2009-10-23 00:00:56.000000000 +0200
@@ -63,12 +63,12 @@
     float     *fPositions;
 
     /**
-     * The auxillary data array.
+     * The auxiliary data arrays.
      *
      * @internal
      */
     le_uint32 *fAuxData;
-
+    void     **fAuxParam;
 
     /**
      * The insertion list, used to grow the above arrays.
@@ -299,6 +299,7 @@
      * @stable ICU 3.6
      */
     le_uint32 getAuxData(le_int32 glyphIndex, LEErrorCode &success) const;
+    void *getAuxParam(le_int32 glyphIndex, LEErrorCode &success) const;
 
     /**
      * This operator allows direct access to the glyph array
@@ -428,15 +429,20 @@
     void adjustPosition(le_int32 glyphIndex, float xAdjust, float yAdjust, LEErrorCode &success);
 
     /**
-     * Set the auxillary data for a particular glyph.
+     * Set the auxiliary data for a particular glyph.
      *
      * @param glyphIndex the index of the glyph
-     * @param auxData the new auxillary data
-     * @param success will be set to an error code if the auxillary data cannot be set.
+     * @param auxData the new auxiliary data
+     * @param auxParam the new secondary auxiliary data (parameter)
+     * @param success will be set to an error code if the auxiliary data cannot be set.
      *
-     * @stable ICU 3.6
+     * @stable ICU 3.6 - mod for XeTeX
+     */
+    void setAuxData(le_int32 glyphIndex, le_uint32 auxData, void *auxParam, LEErrorCode &success);
+    /**
+     * The common case when @param auxParam is <code>NULL</code>.
      */
-    void setAuxData(le_int32 glyphIndex, le_uint32 auxData, LEErrorCode &success);
+    inline void setAuxData(le_int32 glyphIndex, le_uint32 auxData, LEErrorCode &success);
 
     /**
      * Delete the glyph array and replace it with the one
@@ -541,6 +547,10 @@
     return fGlyphs[glyphIndex];
 }
 
+inline void LEGlyphStorage::setAuxData(le_int32 glyphIndex, le_uint32 auxData, LEErrorCode &success)
+{
+    setAuxData(glyphIndex, auxData, NULL, success);
+}
 
 U_NAMESPACE_END
 #endif
diff -ur icu-4.2.1.orig/source/layout/OpenTypeLayoutEngine.cpp icu-4.2.1/source/layout/OpenTypeLayoutEngine.cpp
--- icu-4.2.1.orig/source/layout/OpenTypeLayoutEngine.cpp	2009-07-01 20:51:24.000000000 +0200
+++ icu-4.2.1/source/layout/OpenTypeLayoutEngine.cpp	2009-10-23 00:04:31.000000000 +0200
@@ -73,7 +73,7 @@
 OpenTypeLayoutEngine::OpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
                         le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable, LEErrorCode &success)
     : LayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success), fFeatureMask(minimalFeatures),
-      fFeatureMap(featureMap), fFeatureMapCount(featureMapCount), fFeatureOrder(FALSE),
+      fFeatureMap(featureMap), fFeatureParamList(NULL), fFeatureMapCount(featureMapCount), fFeatureOrder(FALSE),
       fGSUBTable(gsubTable), fGDEFTable(NULL), fGPOSTable(NULL), fSubstitutionFilter(NULL)
 {
     static const le_uint32 gdefTableTag = LE_GDEF_TABLE_TAG;
@@ -200,7 +200,7 @@
     glyphStorage.allocateAuxData(success);
 
     for (le_int32 i = 0; i < count; i += 1) {
-        glyphStorage.setAuxData(i, fFeatureMask, success);
+        glyphStorage.setAuxData(i, fFeatureMask, (void *) fFeatureParamList, success);
     }
 
     return count;
diff -ur icu-4.2.1.orig/source/layout/OpenTypeLayoutEngine.h icu-4.2.1/source/layout/OpenTypeLayoutEngine.h
--- icu-4.2.1.orig/source/layout/OpenTypeLayoutEngine.h	2009-07-01 20:51:24.000000000 +0200
+++ icu-4.2.1/source/layout/OpenTypeLayoutEngine.h	2009-10-23 00:00:56.000000000 +0200
@@ -176,6 +176,7 @@
      * @internal
      */
     const FeatureMap *fFeatureMap;
+    const le_int32 *fFeatureParamList;
 
     /**
      * The length of the feature map.