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