18393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius/*
28393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius *
38393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius * (C) Copyright IBM Corp.  and others 1998-2013 - All Rights Reserved
48393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius *
58393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius */
68393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius
78393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius#include "LETypes.h"
88393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius#include "MorphTables.h"
98393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius#include "SubtableProcessor2.h"
108393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius#include "NonContextualGlyphSubst.h"
118393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius#include "NonContextualGlyphSubstProc2.h"
128393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius#include "SegmentSingleProcessor2.h"
138393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius#include "LEGlyphStorage.h"
148393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius#include "LESwaps.h"
158393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius
168393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig CorneliusU_NAMESPACE_BEGIN
178393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius
188393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig CorneliusUOBJECT_DEFINE_RTTI_IMPLEMENTATION(SegmentSingleProcessor2)
198393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius
208393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig CorneliusSegmentSingleProcessor2::SegmentSingleProcessor2()
218393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius{
228393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius}
238393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius
2459d709d503bab6e2b61931737e662dd293b40578ccorneliusSegmentSingleProcessor2::SegmentSingleProcessor2(const LEReferenceTo<MorphSubtableHeader2> &morphSubtableHeader, LEErrorCode &success)
2559d709d503bab6e2b61931737e662dd293b40578ccornelius  : NonContextualGlyphSubstitutionProcessor2(morphSubtableHeader, success)
268393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius{
2759d709d503bab6e2b61931737e662dd293b40578ccornelius  const LEReferenceTo<NonContextualGlyphSubstitutionHeader2> header(morphSubtableHeader, success);
288393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius
2959d709d503bab6e2b61931737e662dd293b40578ccornelius  segmentSingleLookupTable = LEReferenceTo<SegmentSingleLookupTable>(morphSubtableHeader, success, &header->table);
308393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius}
318393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius
328393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig CorneliusSegmentSingleProcessor2::~SegmentSingleProcessor2()
338393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius{
348393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius}
358393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius
3659d709d503bab6e2b61931737e662dd293b40578ccorneliusvoid SegmentSingleProcessor2::process(LEGlyphStorage &glyphStorage, LEErrorCode &success)
378393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius{
388393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius    const LookupSegment *segments = segmentSingleLookupTable->segments;
398393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius    le_int32 glyphCount = glyphStorage.getGlyphCount();
408393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius    le_int32 glyph;
418393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius
428393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius    for (glyph = 0; glyph < glyphCount; glyph += 1) {
438393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius        LEGlyphID thisGlyph = glyphStorage[glyph];
4459d709d503bab6e2b61931737e662dd293b40578ccornelius        const LookupSegment *lookupSegment = segmentSingleLookupTable->lookupSegment(segmentSingleLookupTable, segments, thisGlyph, success);
458393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius
4659d709d503bab6e2b61931737e662dd293b40578ccornelius        if (lookupSegment != NULL && LE_SUCCESS(success)) {
478393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius            TTGlyphID   newGlyph  = (TTGlyphID) LE_GET_GLYPH(thisGlyph) + SWAPW(lookupSegment->value);
488393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius
498393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius            glyphStorage[glyph] = LE_SET_GLYPH(thisGlyph, newGlyph);
508393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius        }
518393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius    }
528393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius}
538393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius
548393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig CorneliusU_NAMESPACE_END
55