author | prr |
Mon, 01 Jul 2013 12:39:26 -0700 | |
changeset 18518 | 153791a0895c |
parent 16891 | 91e99bed64ae |
child 22330 | cafb826672bd |
permissions | -rw-r--r-- |
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 |
* |
|
28 |
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved |
|
29 |
* |
|
30 |
*/ |
|
31 |
||
32 |
#include "LETypes.h" |
|
33 |
#include "OpenTypeTables.h" |
|
34 |
#include "GlyphDefinitionTables.h" |
|
35 |
#include "GlyphPositionAdjustments.h" |
|
36 |
#include "GlyphIterator.h" |
|
37 |
#include "LEGlyphStorage.h" |
|
38 |
#include "Lookups.h" |
|
39 |
#include "LESwaps.h" |
|
40 |
||
3935 | 41 |
U_NAMESPACE_BEGIN |
2 | 42 |
|
3935 | 43 |
GlyphIterator::GlyphIterator(LEGlyphStorage &theGlyphStorage, GlyphPositionAdjustments *theGlyphPositionAdjustments, le_bool rightToLeft, le_uint16 theLookupFlags, |
16891 | 44 |
FeatureMask theFeatureMask, const LEReferenceTo<GlyphDefinitionTableHeader> &theGlyphDefinitionTableHeader) |
2 | 45 |
: direction(1), position(-1), nextLimit(-1), prevLimit(-1), |
46 |
glyphStorage(theGlyphStorage), glyphPositionAdjustments(theGlyphPositionAdjustments), |
|
7486 | 47 |
srcIndex(-1), destIndex(-1), lookupFlags(theLookupFlags), featureMask(theFeatureMask), glyphGroup(0), |
16891 | 48 |
glyphClassDefinitionTable(), markAttachClassDefinitionTable() |
2 | 49 |
|
50 |
{ |
|
16891 | 51 |
LEErrorCode success = LE_NO_ERROR; // TODO |
2 | 52 |
le_int32 glyphCount = glyphStorage.getGlyphCount(); |
53 |
||
16891 | 54 |
if (theGlyphDefinitionTableHeader.isValid()) { |
55 |
glyphClassDefinitionTable = theGlyphDefinitionTableHeader |
|
56 |
-> getGlyphClassDefinitionTable(theGlyphDefinitionTableHeader, success); |
|
57 |
markAttachClassDefinitionTable = theGlyphDefinitionTableHeader |
|
58 |
->getMarkAttachClassDefinitionTable(theGlyphDefinitionTableHeader, success); |
|
2 | 59 |
} |
60 |
||
61 |
nextLimit = glyphCount; |
|
62 |
||
63 |
if (rightToLeft) { |
|
64 |
direction = -1; |
|
65 |
position = glyphCount; |
|
66 |
nextLimit = -1; |
|
67 |
prevLimit = glyphCount; |
|
68 |
} |
|
18518
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
69 |
filterResetCache(); |
2 | 70 |
} |
71 |
||
72 |
GlyphIterator::GlyphIterator(GlyphIterator &that) |
|
73 |
: glyphStorage(that.glyphStorage) |
|
74 |
{ |
|
75 |
direction = that.direction; |
|
76 |
position = that.position; |
|
77 |
nextLimit = that.nextLimit; |
|
78 |
prevLimit = that.prevLimit; |
|
79 |
||
80 |
glyphPositionAdjustments = that.glyphPositionAdjustments; |
|
81 |
srcIndex = that.srcIndex; |
|
82 |
destIndex = that.destIndex; |
|
83 |
lookupFlags = that.lookupFlags; |
|
84 |
featureMask = that.featureMask; |
|
7486 | 85 |
glyphGroup = that.glyphGroup; |
2 | 86 |
glyphClassDefinitionTable = that.glyphClassDefinitionTable; |
87 |
markAttachClassDefinitionTable = that.markAttachClassDefinitionTable; |
|
18518
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
88 |
filterResetCache(); |
2 | 89 |
} |
90 |
||
91 |
GlyphIterator::GlyphIterator(GlyphIterator &that, FeatureMask newFeatureMask) |
|
92 |
: glyphStorage(that.glyphStorage) |
|
93 |
{ |
|
94 |
direction = that.direction; |
|
95 |
position = that.position; |
|
96 |
nextLimit = that.nextLimit; |
|
97 |
prevLimit = that.prevLimit; |
|
98 |
||
99 |
glyphPositionAdjustments = that.glyphPositionAdjustments; |
|
100 |
srcIndex = that.srcIndex; |
|
101 |
destIndex = that.destIndex; |
|
102 |
lookupFlags = that.lookupFlags; |
|
103 |
featureMask = newFeatureMask; |
|
7486 | 104 |
glyphGroup = 0; |
2 | 105 |
glyphClassDefinitionTable = that.glyphClassDefinitionTable; |
106 |
markAttachClassDefinitionTable = that.markAttachClassDefinitionTable; |
|
18518
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
107 |
filterResetCache(); |
2 | 108 |
} |
109 |
||
110 |
GlyphIterator::GlyphIterator(GlyphIterator &that, le_uint16 newLookupFlags) |
|
111 |
: glyphStorage(that.glyphStorage) |
|
112 |
{ |
|
113 |
direction = that.direction; |
|
114 |
position = that.position; |
|
115 |
nextLimit = that.nextLimit; |
|
116 |
prevLimit = that.prevLimit; |
|
117 |
||
118 |
glyphPositionAdjustments = that.glyphPositionAdjustments; |
|
119 |
srcIndex = that.srcIndex; |
|
120 |
destIndex = that.destIndex; |
|
121 |
lookupFlags = newLookupFlags; |
|
122 |
featureMask = that.featureMask; |
|
7486 | 123 |
glyphGroup = that.glyphGroup; |
2 | 124 |
glyphClassDefinitionTable = that.glyphClassDefinitionTable; |
125 |
markAttachClassDefinitionTable = that.markAttachClassDefinitionTable; |
|
18518
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
126 |
filterResetCache(); |
2 | 127 |
} |
128 |
||
129 |
GlyphIterator::~GlyphIterator() |
|
130 |
{ |
|
131 |
// nothing to do, right? |
|
132 |
} |
|
133 |
||
134 |
void GlyphIterator::reset(le_uint16 newLookupFlags, FeatureMask newFeatureMask) |
|
135 |
{ |
|
136 |
position = prevLimit; |
|
137 |
featureMask = newFeatureMask; |
|
7486 | 138 |
glyphGroup = 0; |
2 | 139 |
lookupFlags = newLookupFlags; |
18518
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
140 |
filterResetCache(); |
2 | 141 |
} |
142 |
||
7486 | 143 |
LEGlyphID *GlyphIterator::insertGlyphs(le_int32 count, LEErrorCode& success) |
2 | 144 |
{ |
7486 | 145 |
return glyphStorage.insertGlyphs(position, count, success); |
2 | 146 |
} |
147 |
||
148 |
le_int32 GlyphIterator::applyInsertions() |
|
149 |
{ |
|
150 |
le_int32 newGlyphCount = glyphStorage.applyInsertions(); |
|
151 |
||
152 |
if (direction < 0) { |
|
153 |
prevLimit = newGlyphCount; |
|
154 |
} else { |
|
155 |
nextLimit = newGlyphCount; |
|
156 |
} |
|
157 |
||
158 |
return newGlyphCount; |
|
159 |
} |
|
160 |
||
161 |
le_int32 GlyphIterator::getCurrStreamPosition() const |
|
162 |
{ |
|
163 |
return position; |
|
164 |
} |
|
165 |
||
166 |
le_bool GlyphIterator::isRightToLeft() const |
|
167 |
{ |
|
168 |
return direction < 0; |
|
169 |
} |
|
170 |
||
171 |
le_bool GlyphIterator::ignoresMarks() const |
|
172 |
{ |
|
173 |
return (lookupFlags & lfIgnoreMarks) != 0; |
|
174 |
} |
|
175 |
||
176 |
le_bool GlyphIterator::baselineIsLogicalEnd() const |
|
177 |
{ |
|
178 |
return (lookupFlags & lfBaselineIsLogicalEnd) != 0; |
|
179 |
} |
|
180 |
||
181 |
LEGlyphID GlyphIterator::getCurrGlyphID() const |
|
182 |
{ |
|
183 |
if (direction < 0) { |
|
184 |
if (position <= nextLimit || position >= prevLimit) { |
|
185 |
return 0xFFFF; |
|
186 |
} |
|
187 |
} else { |
|
188 |
if (position <= prevLimit || position >= nextLimit) { |
|
189 |
return 0xFFFF; |
|
190 |
} |
|
191 |
} |
|
192 |
||
193 |
return glyphStorage[position]; |
|
194 |
} |
|
195 |
||
196 |
void GlyphIterator::getCursiveEntryPoint(LEPoint &entryPoint) const |
|
197 |
{ |
|
198 |
if (direction < 0) { |
|
199 |
if (position <= nextLimit || position >= prevLimit) { |
|
200 |
return; |
|
201 |
} |
|
202 |
} else { |
|
203 |
if (position <= prevLimit || position >= nextLimit) { |
|
204 |
return; |
|
205 |
} |
|
206 |
} |
|
207 |
||
208 |
glyphPositionAdjustments->getEntryPoint(position, entryPoint); |
|
209 |
} |
|
210 |
||
211 |
void GlyphIterator::getCursiveExitPoint(LEPoint &exitPoint) const |
|
212 |
{ |
|
213 |
if (direction < 0) { |
|
214 |
if (position <= nextLimit || position >= prevLimit) { |
|
215 |
return; |
|
216 |
} |
|
217 |
} else { |
|
218 |
if (position <= prevLimit || position >= nextLimit) { |
|
219 |
return; |
|
220 |
} |
|
221 |
} |
|
222 |
||
223 |
glyphPositionAdjustments->getExitPoint(position, exitPoint); |
|
224 |
} |
|
225 |
||
226 |
void GlyphIterator::setCurrGlyphID(TTGlyphID glyphID) |
|
227 |
{ |
|
228 |
LEGlyphID glyph = glyphStorage[position]; |
|
229 |
||
230 |
glyphStorage[position] = LE_SET_GLYPH(glyph, glyphID); |
|
231 |
} |
|
232 |
||
233 |
void GlyphIterator::setCurrStreamPosition(le_int32 newPosition) |
|
234 |
{ |
|
235 |
if (direction < 0) { |
|
236 |
if (newPosition >= prevLimit) { |
|
237 |
position = prevLimit; |
|
238 |
return; |
|
239 |
} |
|
240 |
||
241 |
if (newPosition <= nextLimit) { |
|
242 |
position = nextLimit; |
|
243 |
return; |
|
244 |
} |
|
245 |
} else { |
|
246 |
if (newPosition <= prevLimit) { |
|
247 |
position = prevLimit; |
|
248 |
return; |
|
249 |
} |
|
250 |
||
251 |
if (newPosition >= nextLimit) { |
|
252 |
position = nextLimit; |
|
253 |
return; |
|
254 |
} |
|
255 |
} |
|
256 |
||
257 |
position = newPosition - direction; |
|
258 |
next(); |
|
259 |
} |
|
260 |
||
261 |
void GlyphIterator::setCurrGlyphBaseOffset(le_int32 baseOffset) |
|
262 |
{ |
|
263 |
if (direction < 0) { |
|
264 |
if (position <= nextLimit || position >= prevLimit) { |
|
265 |
return; |
|
266 |
} |
|
267 |
} else { |
|
268 |
if (position <= prevLimit || position >= nextLimit) { |
|
269 |
return; |
|
270 |
} |
|
271 |
} |
|
272 |
||
273 |
glyphPositionAdjustments->setBaseOffset(position, baseOffset); |
|
274 |
} |
|
275 |
||
3935 | 276 |
void GlyphIterator::adjustCurrGlyphPositionAdjustment(float xPlacementAdjust, float yPlacementAdjust, |
277 |
float xAdvanceAdjust, float yAdvanceAdjust) |
|
2 | 278 |
{ |
279 |
if (direction < 0) { |
|
280 |
if (position <= nextLimit || position >= prevLimit) { |
|
281 |
return; |
|
282 |
} |
|
283 |
} else { |
|
284 |
if (position <= prevLimit || position >= nextLimit) { |
|
285 |
return; |
|
286 |
} |
|
287 |
} |
|
288 |
||
289 |
glyphPositionAdjustments->adjustXPlacement(position, xPlacementAdjust); |
|
290 |
glyphPositionAdjustments->adjustYPlacement(position, yPlacementAdjust); |
|
291 |
glyphPositionAdjustments->adjustXAdvance(position, xAdvanceAdjust); |
|
292 |
glyphPositionAdjustments->adjustYAdvance(position, yAdvanceAdjust); |
|
293 |
} |
|
294 |
||
3935 | 295 |
void GlyphIterator::setCurrGlyphPositionAdjustment(float xPlacementAdjust, float yPlacementAdjust, |
296 |
float xAdvanceAdjust, float yAdvanceAdjust) |
|
2 | 297 |
{ |
298 |
if (direction < 0) { |
|
299 |
if (position <= nextLimit || position >= prevLimit) { |
|
300 |
return; |
|
301 |
} |
|
302 |
} else { |
|
303 |
if (position <= prevLimit || position >= nextLimit) { |
|
304 |
return; |
|
305 |
} |
|
306 |
} |
|
307 |
||
308 |
glyphPositionAdjustments->setXPlacement(position, xPlacementAdjust); |
|
309 |
glyphPositionAdjustments->setYPlacement(position, yPlacementAdjust); |
|
310 |
glyphPositionAdjustments->setXAdvance(position, xAdvanceAdjust); |
|
311 |
glyphPositionAdjustments->setYAdvance(position, yAdvanceAdjust); |
|
312 |
} |
|
313 |
||
7486 | 314 |
void GlyphIterator::clearCursiveEntryPoint() |
315 |
{ |
|
316 |
if (direction < 0) { |
|
317 |
if (position <= nextLimit || position >= prevLimit) { |
|
318 |
return; |
|
319 |
} |
|
320 |
} else { |
|
321 |
if (position <= prevLimit || position >= nextLimit) { |
|
322 |
return; |
|
323 |
} |
|
324 |
} |
|
325 |
||
326 |
glyphPositionAdjustments->clearEntryPoint(position); |
|
327 |
} |
|
328 |
||
329 |
void GlyphIterator::clearCursiveExitPoint() |
|
330 |
{ |
|
331 |
if (direction < 0) { |
|
332 |
if (position <= nextLimit || position >= prevLimit) { |
|
333 |
return; |
|
334 |
} |
|
335 |
} else { |
|
336 |
if (position <= prevLimit || position >= nextLimit) { |
|
337 |
return; |
|
338 |
} |
|
339 |
} |
|
340 |
||
341 |
glyphPositionAdjustments->clearExitPoint(position); |
|
342 |
} |
|
343 |
||
2 | 344 |
void GlyphIterator::setCursiveEntryPoint(LEPoint &entryPoint) |
345 |
{ |
|
346 |
if (direction < 0) { |
|
347 |
if (position <= nextLimit || position >= prevLimit) { |
|
348 |
return; |
|
349 |
} |
|
350 |
} else { |
|
351 |
if (position <= prevLimit || position >= nextLimit) { |
|
352 |
return; |
|
353 |
} |
|
354 |
} |
|
355 |
||
356 |
glyphPositionAdjustments->setEntryPoint(position, entryPoint, baselineIsLogicalEnd()); |
|
357 |
} |
|
358 |
||
359 |
void GlyphIterator::setCursiveExitPoint(LEPoint &exitPoint) |
|
360 |
{ |
|
361 |
if (direction < 0) { |
|
362 |
if (position <= nextLimit || position >= prevLimit) { |
|
363 |
return; |
|
364 |
} |
|
365 |
} else { |
|
366 |
if (position <= prevLimit || position >= nextLimit) { |
|
367 |
return; |
|
368 |
} |
|
369 |
} |
|
370 |
||
371 |
glyphPositionAdjustments->setExitPoint(position, exitPoint, baselineIsLogicalEnd()); |
|
372 |
} |
|
373 |
||
374 |
void GlyphIterator::setCursiveGlyph() |
|
375 |
{ |
|
376 |
if (direction < 0) { |
|
377 |
if (position <= nextLimit || position >= prevLimit) { |
|
378 |
return; |
|
379 |
} |
|
380 |
} else { |
|
381 |
if (position <= prevLimit || position >= nextLimit) { |
|
382 |
return; |
|
383 |
} |
|
384 |
} |
|
385 |
||
386 |
glyphPositionAdjustments->setCursiveGlyph(position, baselineIsLogicalEnd()); |
|
387 |
} |
|
388 |
||
18518
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
389 |
void GlyphIterator::filterResetCache(void) { |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
390 |
filterCacheValid = FALSE; |
2 | 391 |
} |
392 |
||
18518
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
393 |
le_bool GlyphIterator::filterGlyph(le_uint32 index) |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
394 |
{ |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
395 |
LEGlyphID glyphID = glyphStorage[index]; |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
396 |
|
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
397 |
if (!filterCacheValid || filterCache.id != glyphID) { |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
398 |
filterCache.id = glyphID; |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
399 |
|
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
400 |
le_bool &filterResult = filterCache.result; // NB: Making this a reference to accept the updated value, in case |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
401 |
// we want more fancy cacheing in the future. |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
402 |
if (LE_GET_GLYPH(glyphID) >= 0xFFFE) { |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
403 |
filterResult = TRUE; |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
404 |
} else { |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
405 |
LEErrorCode success = LE_NO_ERROR; |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
406 |
le_int32 glyphClass = gcdNoGlyphClass; |
16891 | 407 |
if (glyphClassDefinitionTable.isValid()) { |
408 |
glyphClass = glyphClassDefinitionTable->getGlyphClass(glyphClassDefinitionTable, glyphID, success); |
|
2 | 409 |
} |
18518
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
410 |
switch (glyphClass) { |
2 | 411 |
case gcdNoGlyphClass: |
18518
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
412 |
filterResult = FALSE; |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
413 |
break; |
2 | 414 |
|
415 |
case gcdSimpleGlyph: |
|
18518
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
416 |
filterResult = (lookupFlags & lfIgnoreBaseGlyphs) != 0; |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
417 |
break; |
2 | 418 |
|
419 |
case gcdLigatureGlyph: |
|
18518
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
420 |
filterResult = (lookupFlags & lfIgnoreLigatures) != 0; |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
421 |
break; |
2 | 422 |
|
423 |
case gcdMarkGlyph: |
|
424 |
if ((lookupFlags & lfIgnoreMarks) != 0) { |
|
18518
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
425 |
filterResult = TRUE; |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
426 |
} else { |
2 | 427 |
le_uint16 markAttachType = (lookupFlags & lfMarkAttachTypeMask) >> lfMarkAttachTypeShift; |
428 |
||
16891 | 429 |
if ((markAttachType != 0) && (markAttachClassDefinitionTable.isValid())) { |
18518
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
430 |
filterResult = (markAttachClassDefinitionTable |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
431 |
-> getGlyphClass(markAttachClassDefinitionTable, glyphID, success) != markAttachType); |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
432 |
} else { |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
433 |
filterResult = FALSE; |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
434 |
} |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
435 |
} |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
436 |
break; |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
437 |
|
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
438 |
case gcdComponentGlyph: |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
439 |
filterResult = ((lookupFlags & lfIgnoreBaseGlyphs) != 0); |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
440 |
break; |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
441 |
|
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
442 |
default: |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
443 |
filterResult = FALSE; |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
444 |
break; |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
445 |
} |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
446 |
} |
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
447 |
filterCacheValid = TRUE; |
2 | 448 |
} |
449 |
||
18518
153791a0895c
8015144: Performance regression in ICU OpenType Layout library
prr
parents:
16891
diff
changeset
|
450 |
return filterCache.result; |
2 | 451 |
} |
452 |
||
7486 | 453 |
le_bool GlyphIterator::hasFeatureTag(le_bool matchGroup) const |
2 | 454 |
{ |
455 |
if (featureMask == 0) { |
|
456 |
return TRUE; |
|
457 |
} |
|
458 |
||
459 |
LEErrorCode success = LE_NO_ERROR; |
|
460 |
FeatureMask fm = glyphStorage.getAuxData(position, success); |
|
461 |
||
7486 | 462 |
return ((fm & featureMask) == featureMask) && (!matchGroup || (le_int32)(fm & LE_GLYPH_GROUP_MASK) == glyphGroup); |
2 | 463 |
} |
464 |
||
465 |
le_bool GlyphIterator::findFeatureTag() |
|
466 |
{ |
|
7486 | 467 |
//glyphGroup = 0; |
468 |
||
2 | 469 |
while (nextInternal()) { |
7486 | 470 |
if (hasFeatureTag(FALSE)) { |
471 |
LEErrorCode success = LE_NO_ERROR; |
|
472 |
||
473 |
glyphGroup = (glyphStorage.getAuxData(position, success) & LE_GLYPH_GROUP_MASK); |
|
2 | 474 |
return TRUE; |
475 |
} |
|
476 |
} |
|
477 |
||
478 |
return FALSE; |
|
479 |
} |
|
480 |
||
481 |
||
482 |
le_bool GlyphIterator::nextInternal(le_uint32 delta) |
|
483 |
{ |
|
484 |
le_int32 newPosition = position; |
|
485 |
||
486 |
while (newPosition != nextLimit && delta > 0) { |
|
487 |
do { |
|
488 |
newPosition += direction; |
|
16891 | 489 |
//fprintf(stderr,"%s:%d:%s: newPosition = %d, delta = %d\n", __FILE__, __LINE__, __FUNCTION__, newPosition, delta); |
2 | 490 |
} while (newPosition != nextLimit && filterGlyph(newPosition)); |
491 |
||
492 |
delta -= 1; |
|
493 |
} |
|
494 |
||
495 |
position = newPosition; |
|
496 |
||
16891 | 497 |
//fprintf(stderr,"%s:%d:%s: exit position = %d, delta = %d\n", __FILE__, __LINE__, __FUNCTION__, position, delta); |
2 | 498 |
return position != nextLimit; |
499 |
} |
|
500 |
||
501 |
le_bool GlyphIterator::next(le_uint32 delta) |
|
502 |
{ |
|
7486 | 503 |
return nextInternal(delta) && hasFeatureTag(TRUE); |
2 | 504 |
} |
505 |
||
506 |
le_bool GlyphIterator::prevInternal(le_uint32 delta) |
|
507 |
{ |
|
508 |
le_int32 newPosition = position; |
|
509 |
||
510 |
while (newPosition != prevLimit && delta > 0) { |
|
511 |
do { |
|
512 |
newPosition -= direction; |
|
16891 | 513 |
//fprintf(stderr,"%s:%d:%s: newPosition = %d, delta = %d\n", __FILE__, __LINE__, __FUNCTION__, newPosition, delta); |
2 | 514 |
} while (newPosition != prevLimit && filterGlyph(newPosition)); |
515 |
||
516 |
delta -= 1; |
|
517 |
} |
|
518 |
||
519 |
position = newPosition; |
|
520 |
||
16891 | 521 |
//fprintf(stderr,"%s:%d:%s: exit position = %d, delta = %d\n", __FILE__, __LINE__, __FUNCTION__, position, delta); |
2 | 522 |
return position != prevLimit; |
523 |
} |
|
524 |
||
525 |
le_bool GlyphIterator::prev(le_uint32 delta) |
|
526 |
{ |
|
7486 | 527 |
return prevInternal(delta) && hasFeatureTag(TRUE); |
2 | 528 |
} |
529 |
||
530 |
le_int32 GlyphIterator::getMarkComponent(le_int32 markPosition) const |
|
531 |
{ |
|
532 |
le_int32 component = 0; |
|
533 |
le_int32 posn; |
|
534 |
||
535 |
for (posn = position; posn != markPosition; posn += direction) { |
|
536 |
if (glyphStorage[posn] == 0xFFFE) { |
|
537 |
component += 1; |
|
538 |
} |
|
539 |
} |
|
540 |
||
541 |
return component; |
|
542 |
} |
|
543 |
||
544 |
// This is basically prevInternal except that it |
|
545 |
// doesn't take a delta argument, and it doesn't |
|
546 |
// filter out 0xFFFE glyphs. |
|
547 |
le_bool GlyphIterator::findMark2Glyph() |
|
548 |
{ |
|
549 |
le_int32 newPosition = position; |
|
550 |
||
551 |
do { |
|
552 |
newPosition -= direction; |
|
3935 | 553 |
} while (newPosition != prevLimit && glyphStorage[newPosition] != 0xFFFE && filterGlyph(newPosition)); |
2 | 554 |
|
555 |
position = newPosition; |
|
556 |
||
557 |
return position != prevLimit; |
|
558 |
} |
|
3935 | 559 |
|
560 |
U_NAMESPACE_END |