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 * HanLayoutEngine.h: OpenType processing for Han fonts.
29 *
30 * (C) Copyright IBM Corp. 1998-2008 - All Rights Reserved.
31 */
32
33#ifndef __HANLAYOUTENGINE_H
34#define __HANLAYOUTENGINE_H
35
36#include "LETypes.h"
37#include "LEFontInstance.h"
38#include "LayoutEngine.h"
39#include "OpenTypeLayoutEngine.h"
40
41#include "GlyphSubstitutionTables.h"
42
43U_NAMESPACE_BEGIN
44
45class LEGlyphStorage;
46
47/**
48 * This class implements OpenType layout for Han fonts. It overrides
49 * the characerProcessing method to assign the correct OpenType feature
50 * tags for the CJK language-specific forms.
51 *
52 * @internal
53 */
54class HanOpenTypeLayoutEngine : public OpenTypeLayoutEngine
55{
56public:
57    /**
58     * This is the main constructor. It constructs an instance of HanOpenTypeLayoutEngine for
59     * a particular font, script and language. It takes the GSUB table as a parameter since
60     * LayoutEngine::layoutEngineFactory has to read the GSUB table to know that it has a
61     * Han OpenType font.
62     *
63     * @param fontInstance - the font
64     * @param scriptCode - the script
65     * @param langaugeCode - the language
66     * @param gsubTable - the GSUB table
67     * @param success - set to an error code if the operation fails
68     *
69     * @see LayoutEngine::layoutEngineFactory
70     * @see OpenTypeLayoutEngine
71     * @see ScriptAndLangaugeTags.h for script and language codes
72     *
73     * @internal
74     */
75    HanOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
76                            le_int32 typoFlags, const LEReferenceTo<GlyphSubstitutionTableHeader> &gsubTablem, LEErrorCode &success);
77
78
79    /**
80     * The destructor, virtual for correct polymorphic invocation.
81     *
82     * @internal
83     */
84    virtual ~HanOpenTypeLayoutEngine();
85
86    /**
87     * ICU "poor man's RTTI", returns a UClassID for the actual class.
88     *
89     * @stable ICU 2.8
90     */
91    virtual UClassID getDynamicClassID() const;
92
93    /**
94     * ICU "poor man's RTTI", returns a UClassID for this class.
95     *
96     * @stable ICU 2.8
97     */
98    static UClassID getStaticClassID();
99
100protected:
101
102    /**
103     * This method does Han OpenType character processing. It assigns the OpenType feature
104     * tags to the characters to generate the correct language-specific variants.
105     *
106     * Input parameters:
107     * @param chars - the input character context
108     * @param offset - the index of the first character to process
109     * @param count - the number of characters to process
110     * @param max - the number of characters in the input context
111     * @param rightToLeft - <code>TRUE</code> if the characters are in a right to left directional run
112     * @param glyphStorage - the object holding the glyph storage. The char index and auxillary data arrays will be set.
113     *
114     * Output parameters:
115     * @param outChars - the output character arrayt
116     * @param charIndices - the output character index array
117     * @param featureTags - the output feature tag array
118     * @param success - set to an error code if the operation fails
119     *
120     * @return the output character count
121     *
122     * @internal
123     */
124    virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
125            LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
126
127};
128
129U_NAMESPACE_END
130#endif
131