sl@0: /*
sl@0:  *
sl@0:  * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
sl@0:  *
sl@0:  */
sl@0: 
sl@0: #include "LETypes.h"
sl@0: #include "MorphTables.h"
sl@0: #include "SubtableProcessor.h"
sl@0: #include "NonContextualGlyphSubst.h"
sl@0: #include "NonContextualGlyphSubstProc.h"
sl@0: #include "TrimmedArrayProcessor.h"
sl@0: #include "LEGlyphStorage.h"
sl@0: #include "LESwaps.h"
sl@0: 
sl@0: U_NAMESPACE_BEGIN
sl@0: 
sl@0: UOBJECT_DEFINE_RTTI_IMPLEMENTATION(TrimmedArrayProcessor)
sl@0: 
sl@0: TrimmedArrayProcessor::TrimmedArrayProcessor()
sl@0: {
sl@0: }
sl@0: 
sl@0: TrimmedArrayProcessor::TrimmedArrayProcessor(const MorphSubtableHeader *morphSubtableHeader)
sl@0:   : NonContextualGlyphSubstitutionProcessor(morphSubtableHeader)
sl@0: {
sl@0:     const NonContextualGlyphSubstitutionHeader *header = (const NonContextualGlyphSubstitutionHeader *) morphSubtableHeader;
sl@0: 
sl@0:     trimmedArrayLookupTable = (const TrimmedArrayLookupTable *) &header->table;
sl@0:     firstGlyph = SWAPW(trimmedArrayLookupTable->firstGlyph);
sl@0:     lastGlyph = firstGlyph + SWAPW(trimmedArrayLookupTable->glyphCount);
sl@0: }
sl@0: 
sl@0: TrimmedArrayProcessor::~TrimmedArrayProcessor()
sl@0: {
sl@0: }
sl@0: 
sl@0: void TrimmedArrayProcessor::process(LEGlyphStorage &glyphStorage)
sl@0: {
sl@0:     le_int32 glyphCount = glyphStorage.getGlyphCount();
sl@0:     le_int32 glyph;
sl@0: 
sl@0:     for (glyph = 0; glyph < glyphCount; glyph += 1) {
sl@0:         LEGlyphID thisGlyph = glyphStorage[glyph];
sl@0:         TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(thisGlyph);
sl@0: 
sl@0:         if ((ttGlyph > firstGlyph) && (ttGlyph < lastGlyph)) {
sl@0:             TTGlyphID newGlyph = SWAPW(trimmedArrayLookupTable->valueArray[ttGlyph - firstGlyph]);
sl@0: 
sl@0:             glyphStorage[glyph] = LE_SET_GLYPH(thisGlyph, newGlyph);
sl@0:         }
sl@0:     }
sl@0: } 
sl@0: 
sl@0: U_NAMESPACE_END