X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b75a7d8f3b4adbae880cab104ce2c6a50eee4db2..ef6cf650f4a75c3f97de06b51fa104f2069b9ea2:/icuSources/layout/CursiveAttachmentSubtables.cpp diff --git a/icuSources/layout/CursiveAttachmentSubtables.cpp b/icuSources/layout/CursiveAttachmentSubtables.cpp index 3f4bf766..485c9636 100644 --- a/icuSources/layout/CursiveAttachmentSubtables.cpp +++ b/icuSources/layout/CursiveAttachmentSubtables.cpp @@ -1,96 +1,53 @@ /* - * %W% %E% - * - * (C) Copyright IBM Corp. 1998, 1999, 2000, 2001, 2002 - All Rights Reserved + * (C) Copyright IBM Corp. 1998 - 2015 - All Rights Reserved * */ #include "LETypes.h" -#include "LEFontInstance.h" #include "OpenTypeTables.h" #include "GlyphPositioningTables.h" #include "CursiveAttachmentSubtables.h" #include "AnchorTables.h" #include "GlyphIterator.h" -#include "GlyphPositionAdjustments.h" #include "OpenTypeUtilities.h" #include "LESwaps.h" U_NAMESPACE_BEGIN -le_uint32 CursiveAttachmentSubtable::process(GlyphIterator *glyphIterator, const LEFontInstance *fontInstance) const +le_uint32 CursiveAttachmentSubtable::process(const LEReferenceTo &base, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode &success) const { LEGlyphID glyphID = glyphIterator->getCurrGlyphID(); - le_int32 coverageIndex = getGlyphCoverage(glyphID); + le_int32 coverageIndex = getGlyphCoverage(base, glyphID, success); le_uint16 eeCount = SWAPW(entryExitCount); - if (coverageIndex < 0 || coverageIndex >= eeCount) { - glyphIterator->resetCursiveLastExitPoint(); + LEReferenceToArrayOf + entryExitRecordsArrayRef(base, success, entryExitRecords, coverageIndex); + + if (coverageIndex < 0 || coverageIndex >= eeCount || LE_FAILURE(success)) { + glyphIterator->setCursiveGlyph(); return 0; } - LEPoint entryAnchor, exitAnchor, pixels; - - if (glyphIterator->hasCursiveLastExitPoint() && entryExitRecords[coverageIndex].entryAnchor != 0) { - Offset entryOffset = SWAPW(entryExitRecords[coverageIndex].entryAnchor); + LEPoint entryAnchor, exitAnchor; + Offset entryOffset = SWAPW(entryExitRecords[coverageIndex].entryAnchor); + Offset exitOffset = SWAPW(entryExitRecords[coverageIndex].exitAnchor); + if (entryOffset != 0) { const AnchorTable *entryAnchorTable = (const AnchorTable *) ((char *) this + entryOffset); entryAnchorTable->getAnchor(glyphID, fontInstance, entryAnchor); - glyphIterator->getCursiveLastExitPoint(exitAnchor); - - float anchorDiffX = exitAnchor.fX - entryAnchor.fX; - float anchorDiffY = exitAnchor.fY - entryAnchor.fY; - float baselineAdjustment = glyphIterator->getCursiveBaselineAdjustment(); - - if (glyphIterator->isRightToLeft()) { - LEPoint secondAdvance; - - fontInstance->getGlyphAdvance(glyphID, pixels); - fontInstance->pixelsToUnits(pixels, secondAdvance); - - glyphIterator->adjustCurrGlyphPositionAdjustment(0, anchorDiffY + baselineAdjustment, -(anchorDiffX + secondAdvance.fX), 0); - } else { - LEPoint firstAdvance; - - fontInstance->getGlyphAdvance(glyphIterator->getCursiveLastGlyphID(), pixels); - fontInstance->pixelsToUnits(pixels, firstAdvance); - - glyphIterator->adjustCursiveLastGlyphPositionAdjustment(0, 0, anchorDiffX - firstAdvance.fX, 0); - glyphIterator->adjustCurrGlyphPositionAdjustment(0, anchorDiffY + baselineAdjustment, 0, 0); - } - - glyphIterator->setCursiveBaselineAdjustment(anchorDiffY + baselineAdjustment); + glyphIterator->setCursiveEntryPoint(entryAnchor); + } else { + //glyphIterator->clearCursiveEntryPoint(); } - Offset exitOffset = SWAPW(entryExitRecords[coverageIndex].exitAnchor); - if (exitOffset != 0) { const AnchorTable *exitAnchorTable = (const AnchorTable *) ((char *) this + exitOffset); exitAnchorTable->getAnchor(glyphID, fontInstance, exitAnchor); - - if (!glyphIterator->hasCursiveFirstExitPoint()) { - glyphIterator->setCursiveFirstExitPoint(); - } - - glyphIterator->setCursiveLastExitPoint(exitAnchor); + glyphIterator->setCursiveExitPoint(exitAnchor); } else { - /* - * We've got a glyph which is covered but doesn't have an - * exit point. We call setCursiveLastExitPoint just to set - * the position of this glyph, then resetCursiveLastExitPoint - * to do any baseline adjustments that are required for the - * sequence of attached glyphs. - * - * NOTE: we don't really care about the value of - * extiAnchor, because after we reset the last exit - * point, it won't be used. This is a bit of a hack. - * There should probably be a setCursiveLastExitPoint - * call that doesn't take an anchor... - */ - glyphIterator->setCursiveLastExitPoint(exitAnchor); - glyphIterator->resetCursiveLastExitPoint(); + //glyphIterator->clearCursiveExitPoint(); } return 1;