MorphTables.cpp 4.3 KB
Newer Older
D
duke 已提交
1 2 3 4 5
/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
6
 * published by the Free Software Foundation.  Oracle designates this
D
duke 已提交
7
 * particular file as subject to the "Classpath" exception as provided
8
 * by Oracle in the LICENSE file that accompanied this code.
D
duke 已提交
9 10 11 12 13 14 15 16 17 18 19
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
20 21 22
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
D
duke 已提交
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
 *
 */

/*
 *
 * (C) Copyright IBM Corp. 1998 - 2004 - All Rights Reserved
 *
 */


#include "LETypes.h"
#include "LayoutTables.h"
#include "MorphTables.h"
#include "SubtableProcessor.h"
#include "IndicRearrangementProcessor.h"
#include "ContextualGlyphSubstProc.h"
#include "LigatureSubstProc.h"
#include "NonContextualGlyphSubstProc.h"
//#include "ContextualGlyphInsertionProcessor.h"
#include "LEGlyphStorage.h"
#include "LESwaps.h"

45 46
U_NAMESPACE_BEGIN

P
prr 已提交
47
void MorphTableHeader::process(const LETableReference &base, LEGlyphStorage &glyphStorage, LEErrorCode &success) const
D
duke 已提交
48
{
P
prr 已提交
49 50 51
  le_uint32 chainCount = SWAPL(this->nChains);
  LEReferenceTo<ChainHeader> chainHeader(base, success, chains); // moving header
    LEReferenceToArrayOf<ChainHeader> chainHeaderArray(base, success, chains, chainCount);
D
duke 已提交
52 53
    le_uint32 chain;

P
prr 已提交
54
    for (chain = 0; LE_SUCCESS(success) && (chain < chainCount); chain += 1) {
55 56 57 58
        if (chain > 0) {
            le_uint32 chainLength = SWAPL(chainHeader->chainLength);
            chainHeader.addOffset(chainLength, success);
        }
D
duke 已提交
59 60 61
        FeatureFlags defaultFlags = SWAPL(chainHeader->defaultFlags);
        le_int16 nFeatureEntries = SWAPW(chainHeader->nFeatureEntries);
        le_int16 nSubtables = SWAPW(chainHeader->nSubtables);
P
prr 已提交
62 63
        LEReferenceTo<MorphSubtableHeader> subtableHeader =
          LEReferenceTo<MorphSubtableHeader>(chainHeader,success, &(chainHeader->featureTable[nFeatureEntries]));
D
duke 已提交
64 65
        le_int16 subtable;

P
prr 已提交
66
        for (subtable = 0; LE_SUCCESS(success) && (subtable < nSubtables); subtable += 1) {
67 68 69 70
            if (subtable > 0) {
                le_int16 length = SWAPW(subtableHeader->length);
                subtableHeader.addOffset(length, success);
            }
D
duke 已提交
71 72 73 74
            SubtableCoverage coverage = SWAPW(subtableHeader->coverage);
            FeatureFlags subtableFeatures = SWAPL(subtableHeader->subtableFeatures);

            // should check coverage more carefully...
P
prr 已提交
75 76
            if ((coverage & scfVertical) == 0 && (subtableFeatures & defaultFlags) != 0  && LE_SUCCESS(success)) {
              subtableHeader->process(subtableHeader, glyphStorage, success);
D
duke 已提交
77 78 79 80 81
            }
        }
    }
}

P
prr 已提交
82
void MorphSubtableHeader::process(const LEReferenceTo<MorphSubtableHeader> &base, LEGlyphStorage &glyphStorage, LEErrorCode &success) const
D
duke 已提交
83 84 85 86 87 88
{
    SubtableProcessor *processor = NULL;

    switch (SWAPW(coverage) & scfTypeMask)
    {
    case mstIndicRearrangement:
P
prr 已提交
89
      processor = new IndicRearrangementProcessor(base, success);
D
duke 已提交
90 91 92
        break;

    case mstContextualGlyphSubstitution:
P
prr 已提交
93
      processor = new ContextualGlyphSubstitutionProcessor(base, success);
D
duke 已提交
94 95 96
        break;

    case mstLigatureSubstitution:
P
prr 已提交
97
      processor = new LigatureSubstitutionProcessor(base, success);
D
duke 已提交
98 99 100 101 102 103
        break;

    case mstReservedUnused:
        break;

    case mstNonContextualGlyphSubstitution:
P
prr 已提交
104
      processor = NonContextualGlyphSubstitutionProcessor::createInstance(base, success);
D
duke 已提交
105 106 107 108 109 110 111 112 113 114 115 116 117
        break;

    /*
    case mstContextualGlyphInsertion:
        processor = new ContextualGlyphInsertionProcessor(this);
        break;
    */

    default:
        break;
    }

    if (processor != NULL) {
P
prr 已提交
118 119 120 121
      if(LE_SUCCESS(success)) {
        processor->process(glyphStorage, success);
      }
      delete processor;
D
duke 已提交
122 123
    }
}
124 125

U_NAMESPACE_END
新手
引导
客服 返回
顶部