jdk/src/share/native/sun/font/layout/IndicLayoutEngine.h
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#ifndef __INDICLAYOUTENGINE_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#define __INDICLAYOUTENGINE_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "LETypes.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include "LEFontInstance.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "LEGlyphFilter.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include "LayoutEngine.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include "OpenTypeLayoutEngine.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#include "GlyphSubstitutionTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#include "GlyphDefinitionTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#include "GlyphPositioningTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
class MPreFixups;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
class LEGlyphStorage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * This class implements OpenType layout for Indic OpenType fonts, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * specified by Microsoft in "Creating and Supporting OpenType Fonts for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * Indic Scripts" (http://www.microsoft.com/typography/otspec/indicot/default.htm)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * This class overrides the characterProcessing method to do Indic character processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * and reordering, and the glyphProcessing method to implement post-GSUB processing for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * left matras. (See the MS spec. for more details)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * @internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
class IndicOpenTypeLayoutEngine : public OpenTypeLayoutEngine
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
public:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * This is the main constructor. It constructs an instance of IndicOpenTypeLayoutEngine for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * a particular font, script and language. It takes the GSUB table as a parameter since
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * LayoutEngine::layoutEngineFactory has to read the GSUB table to know that it has an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * Indic OpenType font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @param fontInstance - the font
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * @param scriptCode - the script
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * @param langaugeCode - the language
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * @param gsubTable - the GSUB table
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @see LayoutEngine::layoutEngineFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * @see OpenTypeLayoutEngine
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @see ScriptAndLangaugeTags.h for script and language codes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * @internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        le_int32 scriptCode, le_int32 languageCode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * This constructor is used when the font requires a "canned" GSUB table which can't be known
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * until after this constructor has been invoked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @param fontInstance - the font
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @param scriptCode - the script
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @param langaugeCode - the language
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @see OpenTypeLayoutEngine
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @see ScriptAndLangaugeTags.h for script and language codes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * The destructor, virtual for correct polymorphic invocation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * @internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
   virtual ~IndicOpenTypeLayoutEngine();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
protected:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * This method does Indic OpenType character processing. It assigns the OpenType feature
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * tags to the characters, and may generate output characters which have been reordered. For
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * some Indic scripts, it may also split some vowels, resulting in more output characters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * than input characters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * Input parameters:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @param chars - the input character context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @param offset - the index of the first character to process
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @param count - the number of characters to process
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @param max - the number of characters in the input context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @param rightToLeft - <code>TRUE</code> if the characters are in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *    right to left directional run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @param glyphStorage - the glyph storage object. The glyph and character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *    index arrays will be set. The auxillary data array will be set to the feature tags.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * Output parameters:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @param success - set to an error code if the operation fails
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @return the output character count
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * @internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        le_int32 count, le_int32 max, le_bool rightToLeft,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * This method does character to glyph mapping, applies the GSUB table and applies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * any post GSUB fixups for left matras. It calls OpenTypeLayoutEngine::glyphProcessing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * to do the character to glyph mapping, and apply the GSUB table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * Note that in the case of "canned" GSUB tables, the output glyph indices may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * "fake" glyph indices that need to be converted to "real" glyph indices by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * glyphPostProcessing method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * Input parameters:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @param chars - the input character context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @param offset - the index of the first character to process
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @param count - the number of characters to process
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @param max - the number of characters in the input context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @param rightToLeft - <code>TRUE</code> if the characters are in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *    right to left directional run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @param featureTags - the feature tag array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @param glyphStorage - the glyph storage object. The glyph and char
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *    index arrays will be set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * Output parameters:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @param success - set to an error code if the operation fails
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @return the number of glyphs in the output glyph index array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * Note: if the character index array was already set by the characterProcessing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * method, this method won't change it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    virtual le_int32 glyphProcessing(const LEUnicode chars[], le_int32 offset,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphStorage &glyphStorage,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        LEErrorCode &success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
private:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    MPreFixups *fMPreFixups;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
#endif