jdk/src/share/native/sun/font/layout/KhmerReordering.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
 * (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
 * This file is a modification of the ICU file IndicReordering.h
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * by Jens Herden and Javier Sola for Khmer language
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#ifndef __KHMERREORDERING_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#define __KHMERREORDERING_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "LETypes.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include "OpenTypeTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
class LEGlyphStorage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
// Vocabulary
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
// Base ->
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
//     A consonant or an independent vowel in its full (not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
//     subscript) form. It is the center of the syllable, it can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
//     souranded by coeng (subscript) consonants, vowels, split
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
//     vowels, signs... but there is only one base in a syllable, it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
//     has to be coded as the first character of the syllable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
// split vowel ->
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
//     vowel that has two parts placed separately (e.g. Before and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
//     after the consonant).  Khmer language has five of them. Khmer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
//     split vowels either have one part before the base and one after
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
//     the base or they have a part before the base and a part above
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
//     the base.  The first part of all Khmer split vowels is the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
//     character, identical to the glyph of Khmer dependent vowel SRA
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
//     EI
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
// coeng ->
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
//     modifier used in Khmer to construct coeng (subscript)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
//     consonants differently than indian languages, the coeng
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
//     modifies the consonant that follows it, not the one preceding
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
//     it Each consonant has two forms, the base form and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
//     subscript form the base form is the normal one (using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
//     consonants code-point), the subscript form is displayed when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
//     the combination coeng + consonant is encountered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
// Consonant of type 1 ->
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
//     A consonant which has subscript for that only occupies space
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
//     under a base consonant
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
// Consonant of type 2 ->
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
//     Its subscript form occupies space under and before the base
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
//     (only one, RO)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
// Consonant of Type 3 ->
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
//     Its subscript form occupies space under and after the base
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
//     (KHO, CHHO, THHO, BA, YO, SA)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
// Consonant shifter ->
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
//     Khmer has to series of consonants. The same dependent vowel has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
//     different sounds if it is attached to a consonant of the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
//     series or a consonant of the second series Most consonants have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
//     an equivalent in the other series, but some of theme exist only
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
//     in one series (for example SA). If we want to use the consonant
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
//     SA with a vowel sound that can only be done with a vowel sound
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
//     that corresponds to a vowel accompanying a consonant of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
//     other series, then we need to use a consonant shifter: TRIISAP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
//     or MUSIKATOAN x17C9 y x17CA. TRIISAP changes a first series
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
//     consonant to second series sound and MUSIKATOAN a second series
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
//     consonant to have a first series vowel sound.  Consonant
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
//     shifter are both normally supercript marks, but, when they are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
//     followed by a superscript, they change shape and take the form
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
//     of subscript dependent vowel SRA U.  If they are in the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
//     syllable as a coeng consonant, Unicode 3.0 says that they
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
//     should be typed before the coeng. Unicode 4.0 breaks the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
//     standard and says that it should be placed after the coeng
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
//     consonant.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
// Dependent vowel ->
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
//     In khmer dependent vowels can be placed above, below, before or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
//     after the base Each vowel has its own position. Only one vowel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
//     per syllable is allowed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
// Signs ->
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
//     Khmer has above signs and post signs. Only one above sign
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
//     and/or one post sign are Allowed in a syllable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
// This list must include all types of components that can be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
// inside a syllable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
struct KhmerClassTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    // order is important here! This order must be the same that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    // found in each horizontal line in the statetable for Khmer (file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    // KhmerReordering.cpp).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    enum CharClassValues
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        CC_RESERVED             =  0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        CC_CONSONANT            =  1, // consonant of type 1 or independent vowel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        CC_CONSONANT2           =  2, // Consonant of type 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        CC_CONSONANT3           =  3, // Consonant of type 3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        CC_ZERO_WIDTH_NJ_MARK   =  4, // Zero Width non joiner character (0x200C)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        CC_CONSONANT_SHIFTER    =  5,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        CC_ROBAT                =  6, // Khmer special diacritic accent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                                      // -treated differently in state table
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        CC_COENG                =  7, // Subscript consonant combining character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        CC_DEPENDENT_VOWEL      =  8,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        CC_SIGN_ABOVE           =  9,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        CC_SIGN_AFTER           = 10,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        CC_ZERO_WIDTH_J_MARK    = 11, // Zero width joiner character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        CC_COUNT                = 12  // This is the number of character classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    enum CharClassFlags
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        CF_CLASS_MASK    = 0x0000FFFF,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        CF_CONSONANT     = 0x01000000,  // flag to speed up comparing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        CF_SPLIT_VOWEL   = 0x02000000,  // flag for a split vowel -> the first part
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                                        // is added in front of the syllable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        CF_DOTTED_CIRCLE = 0x04000000,  // add a dotted circle if a character with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                                        // this flag is the first in a syllable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        CF_COENG         = 0x08000000,  // flag to speed up comparing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        CF_SHIFTER       = 0x10000000,  // flag to speed up comparing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        CF_ABOVE_VOWEL   = 0x20000000,  // flag to speed up comparing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        // position flags
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        CF_POS_BEFORE    = 0x00080000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        CF_POS_BELOW     = 0x00040000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        CF_POS_ABOVE     = 0x00020000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        CF_POS_AFTER     = 0x00010000,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        CF_POS_MASK      = 0x000f0000
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    typedef le_uint32 CharClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    typedef le_int32 ScriptFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    LEUnicode firstChar;   // for Khmer this will become x1780
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    LEUnicode lastChar;    //  and this x17DF
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    const CharClass *classTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    CharClass getCharClass(LEUnicode ch) const;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    static const KhmerClassTable *getKhmerClassTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
class KhmerReordering {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
public:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    static le_int32 reorder(const LEUnicode *theChars, le_int32 charCount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        le_int32 scriptCode, LEUnicode *outChars, LEGlyphStorage &glyphStorage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    static const FeatureMap *getFeatureMap(le_int32 &count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
private:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    // do not instantiate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    KhmerReordering();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    static le_int32 findSyllable(const KhmerClassTable *classTable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        const LEUnicode *chars, le_int32 prev, le_int32 charCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
#endif