1/*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.  Oracle designates this
7 * particular file as subject to the "Classpath" exception as provided
8 * by Oracle in the LICENSE file that accompanied this code.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26
27/*
28 *
29 * (C) Copyright IBM Corp. 1998-2008 - All Rights Reserved
30 *
31 * This file is a modification of the ICU file IndicLayoutEngine.h
32 * by Jens Herden and Javier Sola for Khmer language
33 *
34 */
35
36#ifndef __KHMERLAYOUTENGINE_H
37#define __KHMERLAYOUTENGINE_H
38
39// #include "LETypes.h"
40// #include "LEFontInstance.h"
41// #include "LEGlyphFilter.h"
42// #include "LayoutEngine.h"
43// #include "OpenTypeLayoutEngine.h"
44
45// #include "GlyphSubstitutionTables.h"
46// #include "GlyphDefinitionTables.h"
47// #include "GlyphPositioningTables.h"
48
49U_NAMESPACE_BEGIN
50
51// class MPreFixups;
52// class LEGlyphStorage;
53
54/**
55 * This class implements OpenType layout for Khmer OpenType fonts, as
56 * specified by Microsoft in "Creating and Supporting OpenType Fonts for
57 * Khmer Scripts" (http://www.microsoft.com/typography/otspec/indicot/default.htm) TODO: change url
58 *
59 * This class overrides the characterProcessing method to do Khmer character processing
60 * and reordering (See the MS spec. for more details)
61 *
62 * @internal
63 */
64class KhmerOpenTypeLayoutEngine : public OpenTypeLayoutEngine
65{
66public:
67    /**
68     * This is the main constructor. It constructs an instance of KhmerOpenTypeLayoutEngine for
69     * a particular font, script and language. It takes the GSUB table as a parameter since
70     * LayoutEngine::layoutEngineFactory has to read the GSUB table to know that it has an
71     * Khmer OpenType font.
72     *
73     * @param fontInstance - the font
74     * @param scriptCode - the script
75     * @param langaugeCode - the language
76     * @param gsubTable - the GSUB table
77     * @param success - set to an error code if the operation fails
78     *
79     * @see LayoutEngine::layoutEngineFactory
80     * @see OpenTypeLayoutEngine
81     * @see ScriptAndLangaugeTags.h for script and language codes
82     *
83     * @internal
84     */
85    KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
86                            le_int32 typoFlags, const LEReferenceTo<GlyphSubstitutionTableHeader> &gsubTable, LEErrorCode &success);
87
88    /**
89     * This constructor is used when the font requires a "canned" GSUB table which can't be known
90     * until after this constructor has been invoked.
91     *
92     * @param fontInstance - the font
93     * @param scriptCode - the script
94     * @param langaugeCode - the language
95     * @param success - set to an error code if the operation fails
96     *
97     * @see OpenTypeLayoutEngine
98     * @see ScriptAndLangaugeTags.h for script and language codes
99     *
100     * @internal
101     */
102    KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
103                              le_int32 typoFlags, LEErrorCode &success);
104
105    /**
106     * The destructor, virtual for correct polymorphic invocation.
107     *
108     * @internal
109     */
110   virtual ~KhmerOpenTypeLayoutEngine();
111
112    /**
113     * ICU "poor man's RTTI", returns a UClassID for the actual class.
114     *
115     * @stable ICU 2.8
116     */
117    virtual UClassID getDynamicClassID() const;
118
119    /**
120     * ICU "poor man's RTTI", returns a UClassID for this class.
121     *
122     * @stable ICU 2.8
123     */
124    static UClassID getStaticClassID();
125
126protected:
127
128    /**
129     * This method does Khmer OpenType character processing. It assigns the OpenType feature
130     * tags to the characters, and may generate output characters which have been reordered.
131     * It may also split some vowels, resulting in more output characters than input characters.
132     *
133     * Input parameters:
134     * @param chars - the input character context
135     * @param offset - the index of the first character to process
136     * @param count - the number of characters to process
137     * @param max - the number of characters in the input context
138     * @param rightToLeft - <code>TRUE</code> if the characters are in a right to left directional run
139     * @param glyphStorage - the glyph storage object. The glyph and character index arrays will be set.
140     *                       the auxillary data array will be set to the feature tags.
141     *
142     * Output parameters:
143     * @param success - set to an error code if the operation fails
144     *
145     * @return the output character count
146     *
147     * @internal
148     */
149    virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
150            LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
151
152};
153
154U_NAMESPACE_END
155#endif
156
157