jdk/src/share/native/sun/font/layout/GlyphPosnLookupProc.cpp
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 3935 afcdb712a9c5
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * (C) Copyright IBM Corp. 1998 - 2005 - All Rights Reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "LETypes.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "LEFontInstance.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "OpenTypeTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "Features.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "Lookups.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include "ScriptAndLanguage.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "GlyphDefinitionTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include "GlyphPositioningTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include "SinglePositioningSubtables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#include "PairPositioningSubtables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#include "CursiveAttachmentSubtables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#include "MarkToBasePosnSubtables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#include "MarkToLigaturePosnSubtables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#include "MarkToMarkPosnSubtables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
//#include "ContextualPositioningSubtables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#include "ContextualSubstSubtables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
#include "ExtensionSubtables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#include "LookupProcessor.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#include "GlyphPosnLookupProc.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#include "LESwaps.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
// Aside from the names, the contextual positioning subtables are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
// the same as the contextual substitution subtables.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
typedef ContextualSubstitutionSubtable ContextualPositioningSubtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
typedef ChainingContextualSubstitutionSubtable ChainingContextualPositioningSubtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
GlyphPositioningLookupProcessor::GlyphPositioningLookupProcessor(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        const GlyphPositioningTableHeader *glyphPositioningTableHeader,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        LETag scriptTag, LETag languageTag,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    : LookupProcessor(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                      (char *) glyphPositioningTableHeader,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
                      SWAPW(glyphPositioningTableHeader->scriptListOffset),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                      SWAPW(glyphPositioningTableHeader->featureListOffset),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                      SWAPW(glyphPositioningTableHeader->lookupListOffset),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                      scriptTag, languageTag, featureMap, featureMapCount, featureOrder)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    // anything?
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
GlyphPositioningLookupProcessor::GlyphPositioningLookupProcessor()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
le_uint32 GlyphPositioningLookupProcessor::applySubtable(const LookupSubtable *lookupSubtable, le_uint16 lookupType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                                                       GlyphIterator *glyphIterator,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                                                       const LEFontInstance *fontInstance) const
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    le_uint32 delta = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    switch(lookupType)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    case 0:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    case gpstSingle:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        const SinglePositioningSubtable *subtable = (const SinglePositioningSubtable *) lookupSubtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        delta = subtable->process(glyphIterator, fontInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    case gpstPair:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        const PairPositioningSubtable *subtable = (const PairPositioningSubtable *) lookupSubtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        delta = subtable->process(glyphIterator, fontInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    case gpstCursive:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        const CursiveAttachmentSubtable *subtable = (const CursiveAttachmentSubtable *) lookupSubtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        delta = subtable->process(glyphIterator, fontInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    case gpstMarkToBase:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        const MarkToBasePositioningSubtable *subtable = (const MarkToBasePositioningSubtable *) lookupSubtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        delta = subtable->process(glyphIterator, fontInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     case gpstMarkToLigature:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        const MarkToLigaturePositioningSubtable *subtable = (const MarkToLigaturePositioningSubtable *) lookupSubtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        delta = subtable->process(glyphIterator, fontInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    case gpstMarkToMark:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        const MarkToMarkPositioningSubtable *subtable = (const MarkToMarkPositioningSubtable *) lookupSubtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        delta = subtable->process(glyphIterator, fontInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
   case gpstContext:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        const ContextualPositioningSubtable *subtable = (const ContextualPositioningSubtable *) lookupSubtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        delta = subtable->process(this, glyphIterator, fontInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    case gpstChainedContext:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        const ChainingContextualPositioningSubtable *subtable = (const ChainingContextualPositioningSubtable *) lookupSubtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        delta = subtable->process(this, glyphIterator, fontInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    case gpstExtension:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        const ExtensionSubtable *subtable = (const ExtensionSubtable *) lookupSubtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        delta = subtable->process(this, lookupType, glyphIterator, fontInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    return delta;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
GlyphPositioningLookupProcessor::~GlyphPositioningLookupProcessor()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
}