1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * %W% %W%
3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * (C) Copyright IBM Corp. 1998 - 2004 - All Rights Reserved
5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "LETypes.h"
10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "LayoutTables.h"
11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "MorphTables.h"
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "SubtableProcessor.h"
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "IndicRearrangementProcessor.h"
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "ContextualGlyphSubstProc.h"
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "LigatureSubstProc.h"
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "NonContextualGlyphSubstProc.h"
17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru//#include "ContextualGlyphInsertionProcessor.h"
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "LEGlyphStorage.h"
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "LESwaps.h"
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_BEGIN
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruvoid MorphTableHeader::process(LEGlyphStorage &glyphStorage) const
24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    const ChainHeader *chainHeader = chains;
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    le_uint32 chainCount = SWAPL(this->nChains);
27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    le_uint32 chain;
28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    for (chain = 0; chain < chainCount; chain += 1) {
30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        FeatureFlags defaultFlags = SWAPL(chainHeader->defaultFlags);
31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        le_uint32 chainLength = SWAPL(chainHeader->chainLength);
32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        le_int16 nFeatureEntries = SWAPW(chainHeader->nFeatureEntries);
33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        le_int16 nSubtables = SWAPW(chainHeader->nSubtables);
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        const MorphSubtableHeader *subtableHeader =
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            (const MorphSubtableHeader *)&chainHeader->featureTable[nFeatureEntries];
36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        le_int16 subtable;
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        for (subtable = 0; subtable < nSubtables; subtable += 1) {
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            le_int16 length = SWAPW(subtableHeader->length);
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            SubtableCoverage coverage = SWAPW(subtableHeader->coverage);
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            FeatureFlags subtableFeatures = SWAPL(subtableHeader->subtableFeatures);
42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            // should check coverage more carefully...
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            if ((coverage & scfVertical) == 0 && (subtableFeatures & defaultFlags) != 0) {
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                subtableHeader->process(glyphStorage);
46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            }
47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            subtableHeader = (const MorphSubtableHeader *) ((char *)subtableHeader + length);
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        }
50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        chainHeader = (const ChainHeader *)((char *)chainHeader + chainLength);
52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruvoid MorphSubtableHeader::process(LEGlyphStorage &glyphStorage) const
56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    SubtableProcessor *processor = NULL;
58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    switch (SWAPW(coverage) & scfTypeMask)
60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    {
61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    case mstIndicRearrangement:
62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        processor = new IndicRearrangementProcessor(this);
63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        break;
64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    case mstContextualGlyphSubstitution:
66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        processor = new ContextualGlyphSubstitutionProcessor(this);
67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        break;
68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    case mstLigatureSubstitution:
70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        processor = new LigatureSubstitutionProcessor(this);
71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        break;
72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    case mstReservedUnused:
74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        break;
75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    case mstNonContextualGlyphSubstitution:
77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        processor = NonContextualGlyphSubstitutionProcessor::createInstance(this);
78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        break;
79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*
81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    case mstContextualGlyphInsertion:
82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        processor = new ContextualGlyphInsertionProcessor(this);
83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        break;
84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    */
85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    default:
87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        break;
88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    if (processor != NULL) {
91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        processor->process(glyphStorage);
92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru        delete processor;
93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    }
94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_END
97