1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * (C) Copyright IBM Corp. 1998 - 2007 - All Rights Reserved
3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "LETypes.h"
7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "OpenTypeTables.h"
8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "GlyphPositioningTables.h"
9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "CursiveAttachmentSubtables.h"
10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "AnchorTables.h"
11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "GlyphIterator.h"
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "OpenTypeUtilities.h"
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "LESwaps.h"
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_BEGIN
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querule_uint32 CursiveAttachmentSubtable::process(GlyphIterator *glyphIterator, const LEFontInstance *fontInstance) const
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    LEGlyphID glyphID       = glyphIterator->getCurrGlyphID();
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    le_int32  coverageIndex = getGlyphCoverage(glyphID);
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    le_uint16 eeCount       = SWAPW(entryExitCount);
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (coverageIndex < 0 || coverageIndex >= eeCount) {
24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        glyphIterator->setCursiveGlyph();
25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        return 0;
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    LEPoint entryAnchor, exitAnchor;
29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    Offset entryOffset = SWAPW(entryExitRecords[coverageIndex].entryAnchor);
30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    Offset exitOffset  = SWAPW(entryExitRecords[coverageIndex].exitAnchor);
31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (entryOffset != 0) {
33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const AnchorTable *entryAnchorTable = (const AnchorTable *) ((char *) this + entryOffset);
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        entryAnchorTable->getAnchor(glyphID, fontInstance, entryAnchor);
36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        glyphIterator->setCursiveEntryPoint(entryAnchor);
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    } else {
38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        //glyphIterator->clearCursiveEntryPoint();
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (exitOffset != 0) {
42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const AnchorTable *exitAnchorTable = (const AnchorTable *) ((char *) this + exitOffset);
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        exitAnchorTable->getAnchor(glyphID, fontInstance, exitAnchor);
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        glyphIterator->setCursiveExitPoint(exitAnchor);
46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    } else {
47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        //glyphIterator->clearCursiveExitPoint();
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return 1;
51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_END
54