]>
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 "MorphTables.h" | |
9 | #include "SubtableProcessor.h" | |
10 | #include "NonContextualGlyphSubst.h" | |
11 | #include "NonContextualGlyphSubstProc.h" | |
12 | #include "TrimmedArrayProcessor.h" | |
374ca955 | 13 | #include "LEGlyphStorage.h" |
b75a7d8f A |
14 | #include "LESwaps.h" |
15 | ||
16 | U_NAMESPACE_BEGIN | |
17 | ||
374ca955 | 18 | UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TrimmedArrayProcessor) |
b75a7d8f A |
19 | |
20 | TrimmedArrayProcessor::TrimmedArrayProcessor() | |
21 | { | |
22 | } | |
23 | ||
57a6839d A |
24 | TrimmedArrayProcessor::TrimmedArrayProcessor(const LEReferenceTo<MorphSubtableHeader> &morphSubtableHeader, LEErrorCode &success) |
25 | : NonContextualGlyphSubstitutionProcessor(morphSubtableHeader, success), firstGlyph(0), lastGlyph(0) | |
b75a7d8f | 26 | { |
57a6839d | 27 | LEReferenceTo<NonContextualGlyphSubstitutionHeader> header(morphSubtableHeader, success); |
b75a7d8f | 28 | |
57a6839d A |
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); | |
b75a7d8f A |
37 | } |
38 | ||
39 | TrimmedArrayProcessor::~TrimmedArrayProcessor() | |
40 | { | |
41 | } | |
42 | ||
57a6839d | 43 | void TrimmedArrayProcessor::process(LEGlyphStorage &glyphStorage, LEErrorCode &success) |
b75a7d8f | 44 | { |
57a6839d | 45 | if(LE_FAILURE(success)) return; |
374ca955 | 46 | le_int32 glyphCount = glyphStorage.getGlyphCount(); |
b75a7d8f A |
47 | le_int32 glyph; |
48 | ||
49 | for (glyph = 0; glyph < glyphCount; glyph += 1) { | |
374ca955 A |
50 | LEGlyphID thisGlyph = glyphStorage[glyph]; |
51 | TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(thisGlyph); | |
b75a7d8f A |
52 | |
53 | if ((ttGlyph > firstGlyph) && (ttGlyph < lastGlyph)) { | |
54 | TTGlyphID newGlyph = SWAPW(trimmedArrayLookupTable->valueArray[ttGlyph - firstGlyph]); | |
55 | ||
374ca955 | 56 | glyphStorage[glyph] = LE_SET_GLYPH(thisGlyph, newGlyph); |
b75a7d8f A |
57 | } |
58 | } | |
59 | } | |
60 | ||
61 | U_NAMESPACE_END |