os/textandloc/fontservices/textshaperplugin/IcuSource/layout/SegmentArrayProcessor.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/layout/SegmentArrayProcessor.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,60 @@
     1.4 +/*
     1.5 + *
     1.6 + * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
     1.7 + *
     1.8 + */
     1.9 +
    1.10 +#include "LETypes.h"
    1.11 +#include "MorphTables.h"
    1.12 +#include "SubtableProcessor.h"
    1.13 +#include "NonContextualGlyphSubst.h"
    1.14 +#include "NonContextualGlyphSubstProc.h"
    1.15 +#include "SegmentArrayProcessor.h"
    1.16 +#include "LEGlyphStorage.h"
    1.17 +#include "LESwaps.h"
    1.18 +
    1.19 +U_NAMESPACE_BEGIN
    1.20 +
    1.21 +UOBJECT_DEFINE_RTTI_IMPLEMENTATION(SegmentArrayProcessor)
    1.22 +
    1.23 +SegmentArrayProcessor::SegmentArrayProcessor()
    1.24 +{
    1.25 +}
    1.26 +
    1.27 +SegmentArrayProcessor::SegmentArrayProcessor(const MorphSubtableHeader *morphSubtableHeader)
    1.28 +  : NonContextualGlyphSubstitutionProcessor(morphSubtableHeader)
    1.29 +{
    1.30 +    const NonContextualGlyphSubstitutionHeader *header = (const NonContextualGlyphSubstitutionHeader *) morphSubtableHeader;
    1.31 +
    1.32 +    segmentArrayLookupTable = (const SegmentArrayLookupTable *) &header->table;
    1.33 +}
    1.34 +
    1.35 +SegmentArrayProcessor::~SegmentArrayProcessor()
    1.36 +{
    1.37 +}
    1.38 +
    1.39 +void SegmentArrayProcessor::process(LEGlyphStorage &glyphStorage)
    1.40 +{
    1.41 +    const LookupSegment *segments = segmentArrayLookupTable->segments;
    1.42 +    le_int32 glyphCount = glyphStorage.getGlyphCount();
    1.43 +    le_int32 glyph;
    1.44 +
    1.45 +    for (glyph = 0; glyph < glyphCount; glyph += 1) {
    1.46 +        LEGlyphID thisGlyph = glyphStorage[glyph];
    1.47 +        const LookupSegment *lookupSegment = segmentArrayLookupTable->lookupSegment(segments, thisGlyph);
    1.48 +
    1.49 +        if (lookupSegment != NULL)  {
    1.50 +            TTGlyphID firstGlyph = SWAPW(lookupSegment->firstGlyph);
    1.51 +            le_int16  offset = SWAPW(lookupSegment->value);
    1.52 +
    1.53 +            if (offset != 0) {
    1.54 +                TTGlyphID  *glyphArray = (TTGlyphID *) ((char *) subtableHeader + offset);
    1.55 +                TTGlyphID   newGlyph   = SWAPW(glyphArray[LE_GET_GLYPH(thisGlyph) - firstGlyph]);
    1.56 +                
    1.57 +                glyphStorage[glyph] = LE_SET_GLYPH(thisGlyph, newGlyph);
    1.58 +            } 
    1.59 +        }
    1.60 +    }
    1.61 +}
    1.62 + 
    1.63 +U_NAMESPACE_END