39 #include "LESwaps.h" |
39 #include "LESwaps.h" |
40 |
40 |
41 U_NAMESPACE_BEGIN |
41 U_NAMESPACE_BEGIN |
42 |
42 |
43 GlyphIterator::GlyphIterator(LEGlyphStorage &theGlyphStorage, GlyphPositionAdjustments *theGlyphPositionAdjustments, le_bool rightToLeft, le_uint16 theLookupFlags, |
43 GlyphIterator::GlyphIterator(LEGlyphStorage &theGlyphStorage, GlyphPositionAdjustments *theGlyphPositionAdjustments, le_bool rightToLeft, le_uint16 theLookupFlags, |
44 FeatureMask theFeatureMask, const GlyphDefinitionTableHeader *theGlyphDefinitionTableHeader) |
44 FeatureMask theFeatureMask, const LEReferenceTo<GlyphDefinitionTableHeader> &theGlyphDefinitionTableHeader) |
45 : direction(1), position(-1), nextLimit(-1), prevLimit(-1), |
45 : direction(1), position(-1), nextLimit(-1), prevLimit(-1), |
46 glyphStorage(theGlyphStorage), glyphPositionAdjustments(theGlyphPositionAdjustments), |
46 glyphStorage(theGlyphStorage), glyphPositionAdjustments(theGlyphPositionAdjustments), |
47 srcIndex(-1), destIndex(-1), lookupFlags(theLookupFlags), featureMask(theFeatureMask), glyphGroup(0), |
47 srcIndex(-1), destIndex(-1), lookupFlags(theLookupFlags), featureMask(theFeatureMask), glyphGroup(0), |
48 glyphClassDefinitionTable(NULL), markAttachClassDefinitionTable(NULL) |
48 glyphClassDefinitionTable(), markAttachClassDefinitionTable() |
49 |
49 |
50 { |
50 { |
|
51 LEErrorCode success = LE_NO_ERROR; // TODO |
51 le_int32 glyphCount = glyphStorage.getGlyphCount(); |
52 le_int32 glyphCount = glyphStorage.getGlyphCount(); |
52 |
53 |
53 if (theGlyphDefinitionTableHeader != NULL) { |
54 if (theGlyphDefinitionTableHeader.isValid()) { |
54 glyphClassDefinitionTable = theGlyphDefinitionTableHeader->getGlyphClassDefinitionTable(); |
55 glyphClassDefinitionTable = theGlyphDefinitionTableHeader |
55 markAttachClassDefinitionTable = theGlyphDefinitionTableHeader->getMarkAttachClassDefinitionTable(); |
56 -> getGlyphClassDefinitionTable(theGlyphDefinitionTableHeader, success); |
|
57 markAttachClassDefinitionTable = theGlyphDefinitionTableHeader |
|
58 ->getMarkAttachClassDefinitionTable(theGlyphDefinitionTableHeader, success); |
56 } |
59 } |
57 |
60 |
58 nextLimit = glyphCount; |
61 nextLimit = glyphCount; |
59 |
62 |
60 if (rightToLeft) { |
63 if (rightToLeft) { |
378 glyphPositionAdjustments->setCursiveGlyph(position, baselineIsLogicalEnd()); |
381 glyphPositionAdjustments->setCursiveGlyph(position, baselineIsLogicalEnd()); |
379 } |
382 } |
380 |
383 |
381 le_bool GlyphIterator::filterGlyph(le_uint32 index) const |
384 le_bool GlyphIterator::filterGlyph(le_uint32 index) const |
382 { |
385 { |
|
386 LEErrorCode success = LE_NO_ERROR; |
383 LEGlyphID glyphID = glyphStorage[index]; |
387 LEGlyphID glyphID = glyphStorage[index]; |
384 le_int32 glyphClass = gcdNoGlyphClass; |
388 le_int32 glyphClass = gcdNoGlyphClass; |
385 |
389 |
386 if (LE_GET_GLYPH(glyphID) >= 0xFFFE) { |
390 if (LE_GET_GLYPH(glyphID) >= 0xFFFE) { |
387 return TRUE; |
391 return TRUE; |
388 } |
392 } |
389 |
393 |
390 if (glyphClassDefinitionTable != NULL) { |
394 if (glyphClassDefinitionTable.isValid()) { |
391 glyphClass = glyphClassDefinitionTable->getGlyphClass(glyphID); |
395 glyphClass = glyphClassDefinitionTable->getGlyphClass(glyphClassDefinitionTable, glyphID, success); |
392 } |
396 } |
393 |
397 |
394 switch (glyphClass) |
398 switch (glyphClass) |
395 { |
399 { |
396 case gcdNoGlyphClass: |
400 case gcdNoGlyphClass: |
459 le_int32 newPosition = position; |
464 le_int32 newPosition = position; |
460 |
465 |
461 while (newPosition != nextLimit && delta > 0) { |
466 while (newPosition != nextLimit && delta > 0) { |
462 do { |
467 do { |
463 newPosition += direction; |
468 newPosition += direction; |
|
469 //fprintf(stderr,"%s:%d:%s: newPosition = %d, delta = %d\n", __FILE__, __LINE__, __FUNCTION__, newPosition, delta); |
464 } while (newPosition != nextLimit && filterGlyph(newPosition)); |
470 } while (newPosition != nextLimit && filterGlyph(newPosition)); |
465 |
471 |
466 delta -= 1; |
472 delta -= 1; |
467 } |
473 } |
468 |
474 |
469 position = newPosition; |
475 position = newPosition; |
470 |
476 |
|
477 //fprintf(stderr,"%s:%d:%s: exit position = %d, delta = %d\n", __FILE__, __LINE__, __FUNCTION__, position, delta); |
471 return position != nextLimit; |
478 return position != nextLimit; |
472 } |
479 } |
473 |
480 |
474 le_bool GlyphIterator::next(le_uint32 delta) |
481 le_bool GlyphIterator::next(le_uint32 delta) |
475 { |
482 { |
481 le_int32 newPosition = position; |
488 le_int32 newPosition = position; |
482 |
489 |
483 while (newPosition != prevLimit && delta > 0) { |
490 while (newPosition != prevLimit && delta > 0) { |
484 do { |
491 do { |
485 newPosition -= direction; |
492 newPosition -= direction; |
|
493 //fprintf(stderr,"%s:%d:%s: newPosition = %d, delta = %d\n", __FILE__, __LINE__, __FUNCTION__, newPosition, delta); |
486 } while (newPosition != prevLimit && filterGlyph(newPosition)); |
494 } while (newPosition != prevLimit && filterGlyph(newPosition)); |
487 |
495 |
488 delta -= 1; |
496 delta -= 1; |
489 } |
497 } |
490 |
498 |
491 position = newPosition; |
499 position = newPosition; |
492 |
500 |
|
501 //fprintf(stderr,"%s:%d:%s: exit position = %d, delta = %d\n", __FILE__, __LINE__, __FUNCTION__, position, delta); |
493 return position != prevLimit; |
502 return position != prevLimit; |
494 } |
503 } |
495 |
504 |
496 le_bool GlyphIterator::prev(le_uint32 delta) |
505 le_bool GlyphIterator::prev(le_uint32 delta) |
497 { |
506 { |