SinglePositioningSubtables.cpp 3.4 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
 *
 */

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

#include "LETypes.h"
#include "LEFontInstance.h"
#include "OpenTypeTables.h"
#include "GlyphPositioningTables.h"
#include "SinglePositioningSubtables.h"
#include "ValueRecords.h"
#include "GlyphIterator.h"
#include "LESwaps.h"

41 42
U_NAMESPACE_BEGIN

P
prr 已提交
43
le_uint32 SinglePositioningSubtable::process(const LEReferenceTo<SinglePositioningSubtable> &base, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode &success) const
D
duke 已提交
44 45 46 47 48 49 50 51
{
    switch(SWAPW(subtableFormat))
    {
    case 0:
        return 0;

    case 1:
    {
P
prr 已提交
52
      const LEReferenceTo<SinglePositioningFormat1Subtable> subtable(base, success, (const SinglePositioningFormat1Subtable *) this);
D
duke 已提交
53

P
prr 已提交
54
      return subtable->process(subtable, glyphIterator, fontInstance, success);
D
duke 已提交
55 56 57 58
    }

    case 2:
    {
P
prr 已提交
59
      const LEReferenceTo<SinglePositioningFormat2Subtable> subtable(base, success, (const SinglePositioningFormat2Subtable *) this);
D
duke 已提交
60

P
prr 已提交
61
      return subtable->process(subtable, glyphIterator, fontInstance, success);
D
duke 已提交
62 63 64 65 66 67 68
    }

    default:
        return 0;
    }
}

P
prr 已提交
69
le_uint32 SinglePositioningFormat1Subtable::process(const LEReferenceTo<SinglePositioningFormat1Subtable> &base, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode &success) const
D
duke 已提交
70 71
{
    LEGlyphID glyph = glyphIterator->getCurrGlyphID();
P
prr 已提交
72
    le_int32 coverageIndex = getGlyphCoverage(base, glyph, success);
73 74 75
    if (LE_FAILURE(success)) {
        return 0;
    }
D
duke 已提交
76 77 78 79 80 81 82 83 84 85

    if (coverageIndex >= 0) {
        valueRecord.adjustPosition(SWAPW(valueFormat), (const char *) this, *glyphIterator, fontInstance);

        return 1;
    }

    return 0;
}

P
prr 已提交
86
le_uint32 SinglePositioningFormat2Subtable::process(const LEReferenceTo<SinglePositioningFormat2Subtable> &base, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode &success) const
D
duke 已提交
87 88
{
    LEGlyphID glyph = glyphIterator->getCurrGlyphID();
P
prr 已提交
89
    le_int16 coverageIndex = (le_int16) getGlyphCoverage(base, glyph, success);
90 91 92
    if (LE_FAILURE(success)) {
        return 0;
    }
D
duke 已提交
93 94

    if (coverageIndex >= 0) {
95
        valueRecordArray[0].adjustPosition(coverageIndex, SWAPW(valueFormat), (const char *) this, *glyphIterator, fontInstance);
D
duke 已提交
96 97 98 99 100 101

        return 1;
    }

    return 0;
}
102 103

U_NAMESPACE_END