os/textandloc/fontservices/textshaperplugin/IcuSource/layout/SegmentArrayProcessor.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
 *
sl@0
     3
 * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
sl@0
     4
 *
sl@0
     5
 */
sl@0
     6
sl@0
     7
#include "LETypes.h"
sl@0
     8
#include "MorphTables.h"
sl@0
     9
#include "SubtableProcessor.h"
sl@0
    10
#include "NonContextualGlyphSubst.h"
sl@0
    11
#include "NonContextualGlyphSubstProc.h"
sl@0
    12
#include "SegmentArrayProcessor.h"
sl@0
    13
#include "LEGlyphStorage.h"
sl@0
    14
#include "LESwaps.h"
sl@0
    15
sl@0
    16
U_NAMESPACE_BEGIN
sl@0
    17
sl@0
    18
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(SegmentArrayProcessor)
sl@0
    19
sl@0
    20
SegmentArrayProcessor::SegmentArrayProcessor()
sl@0
    21
{
sl@0
    22
}
sl@0
    23
sl@0
    24
SegmentArrayProcessor::SegmentArrayProcessor(const MorphSubtableHeader *morphSubtableHeader)
sl@0
    25
  : NonContextualGlyphSubstitutionProcessor(morphSubtableHeader)
sl@0
    26
{
sl@0
    27
    const NonContextualGlyphSubstitutionHeader *header = (const NonContextualGlyphSubstitutionHeader *) morphSubtableHeader;
sl@0
    28
sl@0
    29
    segmentArrayLookupTable = (const SegmentArrayLookupTable *) &header->table;
sl@0
    30
}
sl@0
    31
sl@0
    32
SegmentArrayProcessor::~SegmentArrayProcessor()
sl@0
    33
{
sl@0
    34
}
sl@0
    35
sl@0
    36
void SegmentArrayProcessor::process(LEGlyphStorage &glyphStorage)
sl@0
    37
{
sl@0
    38
    const LookupSegment *segments = segmentArrayLookupTable->segments;
sl@0
    39
    le_int32 glyphCount = glyphStorage.getGlyphCount();
sl@0
    40
    le_int32 glyph;
sl@0
    41
sl@0
    42
    for (glyph = 0; glyph < glyphCount; glyph += 1) {
sl@0
    43
        LEGlyphID thisGlyph = glyphStorage[glyph];
sl@0
    44
        const LookupSegment *lookupSegment = segmentArrayLookupTable->lookupSegment(segments, thisGlyph);
sl@0
    45
sl@0
    46
        if (lookupSegment != NULL)  {
sl@0
    47
            TTGlyphID firstGlyph = SWAPW(lookupSegment->firstGlyph);
sl@0
    48
            le_int16  offset = SWAPW(lookupSegment->value);
sl@0
    49
sl@0
    50
            if (offset != 0) {
sl@0
    51
                TTGlyphID  *glyphArray = (TTGlyphID *) ((char *) subtableHeader + offset);
sl@0
    52
                TTGlyphID   newGlyph   = SWAPW(glyphArray[LE_GET_GLYPH(thisGlyph) - firstGlyph]);
sl@0
    53
                
sl@0
    54
                glyphStorage[glyph] = LE_SET_GLYPH(thisGlyph, newGlyph);
sl@0
    55
            } 
sl@0
    56
        }
sl@0
    57
    }
sl@0
    58
}
sl@0
    59
 
sl@0
    60
U_NAMESPACE_END