3 * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
8 #include "MorphTables.h"
9 #include "SubtableProcessor.h"
10 #include "NonContextualGlyphSubst.h"
11 #include "NonContextualGlyphSubstProc.h"
12 #include "TrimmedArrayProcessor.h"
13 #include "LEGlyphStorage.h"
18 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TrimmedArrayProcessor)
20 TrimmedArrayProcessor::TrimmedArrayProcessor()
24 TrimmedArrayProcessor::TrimmedArrayProcessor(const LEReferenceTo<MorphSubtableHeader> &morphSubtableHeader, LEErrorCode &success)
25 : NonContextualGlyphSubstitutionProcessor(morphSubtableHeader, success), firstGlyph(0), lastGlyph(0)
27 LEReferenceTo<NonContextualGlyphSubstitutionHeader> header(morphSubtableHeader, success);
29 if(LE_FAILURE(success)) return;
31 trimmedArrayLookupTable = LEReferenceTo<TrimmedArrayLookupTable>(morphSubtableHeader, success, (const TrimmedArrayLookupTable*)&header->table);
33 if(LE_FAILURE(success)) return;
35 firstGlyph = SWAPW(trimmedArrayLookupTable->firstGlyph);
36 lastGlyph = firstGlyph + SWAPW(trimmedArrayLookupTable->glyphCount);
39 TrimmedArrayProcessor::~TrimmedArrayProcessor()
43 void TrimmedArrayProcessor::process(LEGlyphStorage &glyphStorage, LEErrorCode &success)
45 if(LE_FAILURE(success)) return;
46 le_int32 glyphCount = glyphStorage.getGlyphCount();
49 for (glyph = 0; glyph < glyphCount; glyph += 1) {
50 LEGlyphID thisGlyph = glyphStorage[glyph];
51 TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(thisGlyph);
53 if ((ttGlyph > firstGlyph) && (ttGlyph < lastGlyph)) {
54 TTGlyphID newGlyph = SWAPW(trimmedArrayLookupTable->valueArray[ttGlyph - firstGlyph]);
56 glyphStorage[glyph] = LE_SET_GLYPH(thisGlyph, newGlyph);