sl@0
|
1 |
/*
|
sl@0
|
2 |
* %W% %E%
|
sl@0
|
3 |
*
|
sl@0
|
4 |
* (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved
|
sl@0
|
5 |
*
|
sl@0
|
6 |
*/
|
sl@0
|
7 |
|
sl@0
|
8 |
#include "LETypes.h"
|
sl@0
|
9 |
#include "LEGlyphFilter.h"
|
sl@0
|
10 |
#include "OpenTypeTables.h"
|
sl@0
|
11 |
#include "GlyphSubstitutionTables.h"
|
sl@0
|
12 |
#include "LigatureSubstSubtables.h"
|
sl@0
|
13 |
#include "GlyphIterator.h"
|
sl@0
|
14 |
#include "LESwaps.h"
|
sl@0
|
15 |
|
sl@0
|
16 |
U_NAMESPACE_BEGIN
|
sl@0
|
17 |
|
sl@0
|
18 |
le_uint32 LigatureSubstitutionSubtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const
|
sl@0
|
19 |
{
|
sl@0
|
20 |
LEGlyphID glyph = glyphIterator->getCurrGlyphID();
|
sl@0
|
21 |
le_int32 coverageIndex = getGlyphCoverage(glyph);
|
sl@0
|
22 |
|
sl@0
|
23 |
if (coverageIndex >= 0) {
|
sl@0
|
24 |
Offset ligSetTableOffset = SWAPW(ligSetTableOffsetArray[coverageIndex]);
|
sl@0
|
25 |
const LigatureSetTable *ligSetTable = (const LigatureSetTable *) ((char *) this + ligSetTableOffset);
|
sl@0
|
26 |
le_uint16 ligCount = SWAPW(ligSetTable->ligatureCount);
|
sl@0
|
27 |
|
sl@0
|
28 |
for (le_uint16 lig = 0; lig < ligCount; lig += 1) {
|
sl@0
|
29 |
Offset ligTableOffset = SWAPW(ligSetTable->ligatureTableOffsetArray[lig]);
|
sl@0
|
30 |
const LigatureTable *ligTable = (const LigatureTable *) ((char *)ligSetTable + ligTableOffset);
|
sl@0
|
31 |
le_uint16 compCount = SWAPW(ligTable->compCount) - 1;
|
sl@0
|
32 |
le_int32 startPosition = glyphIterator->getCurrStreamPosition();
|
sl@0
|
33 |
TTGlyphID ligGlyph = SWAPW(ligTable->ligGlyph);
|
sl@0
|
34 |
le_uint16 comp;
|
sl@0
|
35 |
|
sl@0
|
36 |
if (filter != NULL && ! filter->accept(LE_SET_GLYPH(glyph, ligGlyph))) {
|
sl@0
|
37 |
continue;
|
sl@0
|
38 |
}
|
sl@0
|
39 |
|
sl@0
|
40 |
for (comp = 0; comp < compCount; comp += 1) {
|
sl@0
|
41 |
if (! glyphIterator->next()) {
|
sl@0
|
42 |
break;
|
sl@0
|
43 |
}
|
sl@0
|
44 |
|
sl@0
|
45 |
if (LE_GET_GLYPH(glyphIterator->getCurrGlyphID()) != SWAPW(ligTable->componentArray[comp])) {
|
sl@0
|
46 |
break;
|
sl@0
|
47 |
}
|
sl@0
|
48 |
}
|
sl@0
|
49 |
|
sl@0
|
50 |
if (comp == compCount) {
|
sl@0
|
51 |
GlyphIterator tempIterator(*glyphIterator);
|
sl@0
|
52 |
TTGlyphID deletedGlyph = tempIterator.ignoresMarks()? 0xFFFE : 0xFFFF;
|
sl@0
|
53 |
|
sl@0
|
54 |
while (comp > 0) {
|
sl@0
|
55 |
tempIterator.setCurrGlyphID(deletedGlyph);
|
sl@0
|
56 |
tempIterator.prev();
|
sl@0
|
57 |
|
sl@0
|
58 |
comp -= 1;
|
sl@0
|
59 |
}
|
sl@0
|
60 |
|
sl@0
|
61 |
tempIterator.setCurrGlyphID(ligGlyph);
|
sl@0
|
62 |
|
sl@0
|
63 |
return compCount + 1;
|
sl@0
|
64 |
}
|
sl@0
|
65 |
|
sl@0
|
66 |
glyphIterator->setCurrStreamPosition(startPosition);
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
}
|
sl@0
|
70 |
|
sl@0
|
71 |
return 0;
|
sl@0
|
72 |
}
|
sl@0
|
73 |
|
sl@0
|
74 |
U_NAMESPACE_END
|