]> git.saurik.com Git - apple/icu.git/blob - icuSources/layout/TrimmedArrayProcessor.cpp
ICU-531.48.tar.gz
[apple/icu.git] / icuSources / layout / TrimmedArrayProcessor.cpp
1 /*
2 *
3 * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
4 *
5 */
6
7 #include "LETypes.h"
8 #include "MorphTables.h"
9 #include "SubtableProcessor.h"
10 #include "NonContextualGlyphSubst.h"
11 #include "NonContextualGlyphSubstProc.h"
12 #include "TrimmedArrayProcessor.h"
13 #include "LEGlyphStorage.h"
14 #include "LESwaps.h"
15
16 U_NAMESPACE_BEGIN
17
18 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TrimmedArrayProcessor)
19
20 TrimmedArrayProcessor::TrimmedArrayProcessor()
21 {
22 }
23
24 TrimmedArrayProcessor::TrimmedArrayProcessor(const LEReferenceTo<MorphSubtableHeader> &morphSubtableHeader, LEErrorCode &success)
25 : NonContextualGlyphSubstitutionProcessor(morphSubtableHeader, success), firstGlyph(0), lastGlyph(0)
26 {
27 LEReferenceTo<NonContextualGlyphSubstitutionHeader> header(morphSubtableHeader, success);
28
29 if(LE_FAILURE(success)) return;
30
31 trimmedArrayLookupTable = LEReferenceTo<TrimmedArrayLookupTable>(morphSubtableHeader, success, (const TrimmedArrayLookupTable*)&header->table);
32
33 if(LE_FAILURE(success)) return;
34
35 firstGlyph = SWAPW(trimmedArrayLookupTable->firstGlyph);
36 lastGlyph = firstGlyph + SWAPW(trimmedArrayLookupTable->glyphCount);
37 }
38
39 TrimmedArrayProcessor::~TrimmedArrayProcessor()
40 {
41 }
42
43 void TrimmedArrayProcessor::process(LEGlyphStorage &glyphStorage, LEErrorCode &success)
44 {
45 if(LE_FAILURE(success)) return;
46 le_int32 glyphCount = glyphStorage.getGlyphCount();
47 le_int32 glyph;
48
49 for (glyph = 0; glyph < glyphCount; glyph += 1) {
50 LEGlyphID thisGlyph = glyphStorage[glyph];
51 TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(thisGlyph);
52
53 if ((ttGlyph > firstGlyph) && (ttGlyph < lastGlyph)) {
54 TTGlyphID newGlyph = SWAPW(trimmedArrayLookupTable->valueArray[ttGlyph - firstGlyph]);
55
56 glyphStorage[glyph] = LE_SET_GLYPH(thisGlyph, newGlyph);
57 }
58 }
59 }
60
61 U_NAMESPACE_END