1
2/*
3 *
4 * (C) Copyright IBM Corp. 1998-2014 - All Rights Reserved
5 *
6 */
7
8#ifndef __THAILAYOUTENGINE_H
9#define __THAILAYOUTENGINE_H
10
11#include "LETypes.h"
12#include "LEFontInstance.h"
13#include "LayoutEngine.h"
14
15#include "ThaiShaping.h"
16
17U_NAMESPACE_BEGIN
18
19class LEGlyphStorage;
20
21/**
22 * This class implements layout for the Thai script, using the ThaiShapingClass.
23 * All existing Thai fonts use an encoding which assigns character codes to all
24 * the variant forms needed to display accents and tone marks correctly in context.
25 * This class can deal with fonts using the Microsoft, Macintosh, and WorldType encodings.
26 *
27 * @internal
28 */
29class ThaiLayoutEngine : public LayoutEngine
30{
31public:
32    /**
33     * This constructs an instance of ThaiLayoutEngine for the given font, script and
34     * language. It examines the font, using LEFontInstance::canDisplay, to set fGlyphSet
35     * and fErrorChar. (see below)
36     *
37     * @param fontInstance - the font
38     * @param scriptCode - the script
39     * @param languageCode - the language
40     * @param success - set to an error code if the operation fails
41     *
42     * @see LEFontInstance
43     * @see ScriptAndLanguageTags.h for script and language codes
44     *
45     * @internal
46     */
47    ThaiLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags, LEErrorCode &success);
48
49    /**
50     * The destructor, virtual for correct polymorphic invocation.
51     *
52     * @internal
53     */
54    virtual ~ThaiLayoutEngine();
55
56    /**
57     * ICU "poor man's RTTI", returns a UClassID for the actual class.
58     *
59     * @deprecated ICU 54. See {@link icu::LayoutEngine}
60     */
61    virtual UClassID getDynamicClassID() const;
62
63    /**
64     * ICU "poor man's RTTI", returns a UClassID for this class.
65     *
66     * @deprecated ICU 54. See {@link icu::LayoutEngine}
67     */
68    static UClassID getStaticClassID();
69
70protected:
71    /**
72     * A small integer indicating which Thai encoding
73     * the font uses.
74     *
75     * @see ThaiShaping
76     *
77     * @internal
78     */
79    le_uint8 fGlyphSet;
80
81    /**
82     * The character used as a base for vowels and
83     * tone marks that are out of sequence. Usually
84     * this will be Unicode 0x25CC, if the font can
85     * display it.
86     *
87     * @see ThaiShaping
88     *
89     * @internal
90     */
91    LEUnicode fErrorChar;
92
93    /**
94     * This method performs Thai layout. It calls ThaiShaping::compose to
95     * generate the correct contextual character codes, and then calls
96     * mapCharsToGlyphs to generate the glyph indices.
97     *
98     * Input parameters:
99     * @param chars - the input character context
100     * @param offset - the index of the first character to process
101     * @param count - the number of characters to process
102     * @param max - the number of characters in the input context
103     * @param rightToLeft - <code>TRUE</code> if the text is in a right to left directional run
104     * @param glyphStorage - the glyph storage object. The glyph and char index arrays will be set.
105     *
106     * Output parameters:
107     * @param success - set to an error code if the operation fails
108     *
109     * @return the number of glyphs in the glyph index array
110     *
111     * @see ThaiShaping
112     *
113     * @internal
114     */
115    virtual le_int32 computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
116        LEGlyphStorage &glyphStorage, LEErrorCode &success);
117
118    /**
119     * This method does positioning adjustments like accent positioning and
120     * kerning. The default implementation does nothing. Subclasses needing
121     * position adjustments must override this method.
122     *
123     * Note that this method has both characters and glyphs as input so that
124     * it can use the character codes to determine glyph types if that information
125     * isn't directly available. (e.g. Some Arabic OpenType fonts don't have a GDEF
126     * table)
127     *
128     * @param chars - the input character context
129     * @param offset - the offset of the first character to process
130     * @param count - the number of characters to process
131     * @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
132     * @param glyphStorage - the object which holds the per-glyph storage. The glyph positions will be
133     *                       adjusted as needed.
134     * @param success - output parameter set to an error code if the operation fails
135     *
136     * @internal
137     */
138    virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
139
140};
141
142U_NAMESPACE_END
143#endif
144
145