]>
Commit | Line | Data |
---|---|---|
b75a7d8f | 1 | /* |
b75a7d8f | 2 | * |
57a6839d | 3 | * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved |
b75a7d8f A |
4 | * |
5 | */ | |
6 | ||
7 | #include "LETypes.h" | |
8 | #include "LEGlyphFilter.h" | |
9 | #include "OpenTypeTables.h" | |
10 | #include "GlyphSubstitutionTables.h" | |
11 | #include "SingleSubstitutionSubtables.h" | |
12 | #include "GlyphIterator.h" | |
13 | #include "LESwaps.h" | |
14 | ||
15 | U_NAMESPACE_BEGIN | |
16 | ||
57a6839d | 17 | le_uint32 SingleSubstitutionSubtable::process(const LEReferenceTo<SingleSubstitutionSubtable> &base, GlyphIterator *glyphIterator, LEErrorCode &success, const LEGlyphFilter *filter) const |
b75a7d8f A |
18 | { |
19 | switch(SWAPW(subtableFormat)) | |
20 | { | |
21 | case 0: | |
22 | return 0; | |
23 | ||
24 | case 1: | |
25 | { | |
57a6839d | 26 | const LEReferenceTo<SingleSubstitutionFormat1Subtable> subtable(base, success, (const SingleSubstitutionFormat1Subtable *) this); |
b75a7d8f | 27 | |
57a6839d | 28 | return subtable->process(subtable, glyphIterator, success, filter); |
b75a7d8f A |
29 | } |
30 | ||
31 | case 2: | |
32 | { | |
57a6839d | 33 | const LEReferenceTo<SingleSubstitutionFormat2Subtable> subtable(base, success, (const SingleSubstitutionFormat2Subtable *) this); |
b75a7d8f | 34 | |
57a6839d | 35 | return subtable->process(subtable, glyphIterator, success, filter); |
b75a7d8f A |
36 | } |
37 | ||
38 | default: | |
39 | return 0; | |
40 | } | |
41 | } | |
42 | ||
57a6839d | 43 | le_uint32 SingleSubstitutionFormat1Subtable::process(const LEReferenceTo<SingleSubstitutionFormat1Subtable> &base, GlyphIterator *glyphIterator, LEErrorCode &success, const LEGlyphFilter *filter) const |
b75a7d8f A |
44 | { |
45 | LEGlyphID glyph = glyphIterator->getCurrGlyphID(); | |
57a6839d | 46 | le_int32 coverageIndex = getGlyphCoverage(base, glyph, success); |
b75a7d8f A |
47 | |
48 | if (coverageIndex >= 0) { | |
49 | TTGlyphID substitute = ((TTGlyphID) LE_GET_GLYPH(glyph)) + SWAPW(deltaGlyphID); | |
50 | ||
51 | if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, substitute))) { | |
52 | glyphIterator->setCurrGlyphID(substitute); | |
53 | } | |
54 | ||
55 | return 1; | |
56 | } | |
57 | ||
58 | return 0; | |
59 | } | |
60 | ||
57a6839d | 61 | le_uint32 SingleSubstitutionFormat2Subtable::process(const LEReferenceTo<SingleSubstitutionFormat2Subtable> &base, GlyphIterator *glyphIterator, LEErrorCode &success, const LEGlyphFilter *filter) const |
b75a7d8f A |
62 | { |
63 | LEGlyphID glyph = glyphIterator->getCurrGlyphID(); | |
57a6839d | 64 | le_int32 coverageIndex = getGlyphCoverage(base, glyph, success); |
b75a7d8f A |
65 | |
66 | if (coverageIndex >= 0) { | |
67 | TTGlyphID substitute = SWAPW(substituteArray[coverageIndex]); | |
68 | ||
69 | if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, substitute))) { | |
70 | glyphIterator->setCurrGlyphID(substitute); | |
71 | } | |
72 | ||
73 | return 1; | |
74 | } | |
75 | ||
76 | return 0; | |
77 | } | |
78 | ||
79 | U_NAMESPACE_END |