jdk/src/share/native/sun/font/layout/ThaiLayoutEngine.h
author kvn
Tue, 28 Jan 2014 14:57:41 -0800
changeset 22607 ba232b417248
parent 7486 6a36b1ebc620
permissions -rw-r--r--
Merge
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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
     6
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
     8
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
    22
 * questions.
2
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
 *
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    29
 * (C) Copyright IBM Corp. 1998-2010 - All Rights Reserved
2
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 __THAILAYOUTENGINE_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#define __THAILAYOUTENGINE_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 "LayoutEngine.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include "ThaiShaping.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    42
U_NAMESPACE_BEGIN
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    43
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
class LEGlyphStorage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * This class implements layout for the Thai script, using the ThaiShapingClass.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * All existing Thai fonts use an encoding which assigns character codes to all
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * the variant forms needed to display accents and tone marks correctly in context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * This class can deal with fonts using the Microsoft, Macintosh, and WorldType encodings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * @internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
class ThaiLayoutEngine : public LayoutEngine
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
public:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * This constructs an instance of ThaiLayoutEngine for the given font, script and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * language. It examines the font, using LEFontInstance::canDisplay, to set fGlyphSet
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * and fErrorChar. (see below)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * @param fontInstance - the font
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * @param scriptCode - the script
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @param languageCode - the language
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    65
     * @param success - set to an error code if the operation fails
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * @see LEFontInstance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @see ScriptAndLanguageTags.h for script and language codes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * @internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     */
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    72
    ThaiLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags, LEErrorCode &success);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * The destructor, virtual for correct polymorphic invocation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * @internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    virtual ~ThaiLayoutEngine();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    81
    /**
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    82
     * ICU "poor man's RTTI", returns a UClassID for the actual class.
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    83
     *
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    84
     * @stable ICU 2.8
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    85
     */
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    86
    virtual UClassID getDynamicClassID() const;
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    87
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    88
    /**
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    89
     * ICU "poor man's RTTI", returns a UClassID for this class.
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    90
     *
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    91
     * @stable ICU 2.8
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    92
     */
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    93
    static UClassID getStaticClassID();
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    94
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
protected:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * A small integer indicating which Thai encoding
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * the font uses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @see ThaiShaping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    le_uint8 fGlyphSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * The character used as a base for vowels and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * tone marks that are out of sequence. Usually
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * this will be Unicode 0x25CC, if the font can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * display it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @see ThaiShaping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    LEUnicode fErrorChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * This method performs Thai layout. It calls ThaiShaping::compose to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * generate the correct contextual character codes, and then calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * mapCharsToGlyphs to generate the glyph indices.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * Input parameters:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @param chars - the input character context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @param offset - the index of the first character to process
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @param count - the number of characters to process
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @param max - the number of characters in the input context
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   128
     * @param rightToLeft - <code>TRUE</code> if the text is in a right to left directional run
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   129
     * @param glyphStorage - the glyph storage object. The glyph and char index arrays will be set.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * Output parameters:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @param success - set to an error code if the operation fails
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @return the number of glyphs in the glyph index array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * @see ThaiShaping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @internal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     */
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   140
    virtual le_int32 computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        LEGlyphStorage &glyphStorage, LEErrorCode &success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   143
    /**
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   144
     * This method does positioning adjustments like accent positioning and
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   145
     * kerning. The default implementation does nothing. Subclasses needing
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   146
     * position adjustments must override this method.
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   147
     *
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   148
     * Note that this method has both characters and glyphs as input so that
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   149
     * it can use the character codes to determine glyph types if that information
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   150
     * isn't directly available. (e.g. Some Arabic OpenType fonts don't have a GDEF
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   151
     * table)
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   152
     *
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   153
     * @param chars - the input character context
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   154
     * @param offset - the offset of the first character to process
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   155
     * @param count - the number of characters to process
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   156
     * @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   157
     * @param glyphStorage - the object which holds the per-glyph storage. The glyph positions will be
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   158
     *                       adjusted as needed.
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   159
     * @param success - output parameter set to an error code if the operation fails
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   160
     *
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   161
     * @internal
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   162
     */
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   163
    virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   164
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   167
U_NAMESPACE_END
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
#endif
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   169