]> git.saurik.com Git - apple/icu.git/blame - icuSources/layout/ArabicLayoutEngine.h
ICU-511.34.tar.gz
[apple/icu.git] / icuSources / layout / ArabicLayoutEngine.h
CommitLineData
b75a7d8f
A
1
2/*
b75a7d8f 3 *
729e4ab9 4 * (C) Copyright IBM Corp. 1998-2008 - All Rights Reserved
b75a7d8f
A
5 *
6 */
7
8#ifndef __ARABICLAYOUTENGINE_H
9#define __ARABICLAYOUTENGINE_H
10
11#include "LETypes.h"
12#include "LEFontInstance.h"
13#include "LEGlyphFilter.h"
14#include "LayoutEngine.h"
15#include "OpenTypeLayoutEngine.h"
16
17#include "GlyphSubstitutionTables.h"
18#include "GlyphDefinitionTables.h"
19#include "GlyphPositioningTables.h"
20
21U_NAMESPACE_BEGIN
22
23/**
24 * This class implements OpenType layout for Arabic fonts. It overrides
25 * the characerProcessing method to assign the correct OpenType feature
26 * tags for the Arabic contextual forms. It also overrides the adjustGlyphPositions
27 * method to guarantee that all vowel and accent glyphs have zero advance width.
28 *
29 * @internal
30 */
31class ArabicOpenTypeLayoutEngine : public OpenTypeLayoutEngine
32{
33public:
34 /**
35 * This is the main constructor. It constructs an instance of ArabicOpenTypeLayoutEngine for
36 * a particular font, script and language. It takes the GSUB table as a parameter since
37 * LayoutEngine::layoutEngineFactory has to read the GSUB table to know that it has an
38 * Indic OpenType font.
39 *
40 * @param fontInstance - the font
41 * @param scriptCode - the script
42 * @param langaugeCode - the language
43 * @param gsubTable - the GSUB table
729e4ab9 44 * @param success - set to an error code if the operation fails
b75a7d8f
A
45 *
46 * @see LayoutEngine::layoutEngineFactory
47 * @see OpenTypeLayoutEngine
73c04bcf 48 * @see ScriptAndLanguageTags.h for script and language codes
b75a7d8f
A
49 *
50 * @internal
51 */
52 ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
729e4ab9 53 le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable, LEErrorCode &success);
b75a7d8f
A
54
55 /**
56 * This constructor is used when the font requires a "canned" GSUB table which can't be known
57 * until after this constructor has been invoked.
58 *
59 * @param fontInstance - the font
60 * @param scriptCode - the script
61 * @param langaugeCode - the language
729e4ab9 62 * @param success - set to an error code if the operation fails
b75a7d8f
A
63 *
64 * @see OpenTypeLayoutEngine
73c04bcf 65 * @see ScriptAndLanguageTags.h for script and language codes
b75a7d8f
A
66 *
67 * @internal
68 */
73c04bcf 69 ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
729e4ab9 70 le_int32 typoFlags, LEErrorCode &success);
b75a7d8f
A
71
72 /**
73 * The destructor, virtual for correct polymorphic invocation.
74 *
75 * @internal
76 */
77 virtual ~ArabicOpenTypeLayoutEngine();
78
79 /**
80 * ICU "poor man's RTTI", returns a UClassID for the actual class.
81 *
374ca955 82 * @stable ICU 2.8
b75a7d8f 83 */
374ca955 84 virtual UClassID getDynamicClassID() const;
b75a7d8f
A
85
86 /**
87 * ICU "poor man's RTTI", returns a UClassID for this class.
88 *
374ca955 89 * @stable ICU 2.8
b75a7d8f 90 */
374ca955 91 static UClassID getStaticClassID();
b75a7d8f
A
92
93protected:
94
95 /**
96 * This method does Arabic OpenType character processing. It assigns the OpenType feature
97 * tags to the characters to generate the correct contextual forms and ligatures.
98 *
99 * Input parameters:
100 * @param chars - the input character context
101 * @param offset - the index of the first character to process
102 * @param count - the number of characters to process
103 * @param max - the number of characters in the input context
374ca955 104 * @param rightToLeft - <code>TRUE</code> if the characters are in a right to left directional run
b75a7d8f
A
105 *
106 * Output parameters:
107 * @param outChars - the output character arrayt
108 * @param charIndices - the output character index array
109 * @param featureTags - the output feature tag array
110 * @param success - set to an error code if the operation fails
111 *
112 * @return the output character count
113 *
114 * @internal
115 */
116 virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
374ca955 117 LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
b75a7d8f
A
118
119 /**
120 * This method applies the GPOS table if it is present, otherwise it ensures that all vowel
121 * and accent glyphs have a zero advance width by calling the adjustMarkGlyphs method.
122 * If the font contains a GDEF table, that is used to identify voewls and accents. Otherwise
123 * the character codes are used.
124 *
125 * @param chars - the input character context
126 * @param offset - the offset of the first character to process
127 * @param count - the number of characters to process
374ca955 128 * @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
b75a7d8f
A
129 * @param glyphs - the input glyph array
130 * @param glyphCount - the number of glyphs
131 * @param positions - the position array, will be updated as needed
132 * @param success - output parameter set to an error code if the operation fails
133 *
134 * @internal
135 */
374ca955 136 virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
b75a7d8f 137
374ca955 138 // static void adjustMarkGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success);
b75a7d8f 139
b75a7d8f
A
140};
141
142/**
143 * The class implements OpenType layout for Arabic fonts which don't
144 * contain a GSUB table, using a canned GSUB table based on Unicode
145 * Arabic Presentation Forms. It overrides the mapCharsToGlyphs method
146 * to use the Presentation Forms as logical glyph indices. It overrides the
147 * glyphPostProcessing method to convert the Presentation Forms to actual
148 * glyph indices.
149 *
150 * @see ArabicOpenTypeLayoutEngine
151 *
152 * @internal
153 */
154class UnicodeArabicOpenTypeLayoutEngine : public ArabicOpenTypeLayoutEngine
155{
156public:
157 /**
158 * This constructs an instance of UnicodeArabicOpenTypeLayoutEngine for a specific font,
159 * script and language.
160 *
161 * @param fontInstance - the font
162 * @param scriptCode - the script
163 * @param languageCode - the language
729e4ab9 164 * @param success - set to an error code if the operation fails
b75a7d8f
A
165 *
166 * @see LEFontInstance
167 * @see ScriptAndLanguageTags.h for script and language codes
168 *
169 * @internal
170 */
73c04bcf 171 UnicodeArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
729e4ab9 172 le_int32 typoFlags, LEErrorCode &success);
b75a7d8f
A
173
174 /**
175 * The destructor, virtual for correct polymorphic invocation.
176 *
177 * @internal
178 */
179 virtual ~UnicodeArabicOpenTypeLayoutEngine();
180
181protected:
182
183 /**
184 * This method converts the Arabic Presentation Forms in the temp glyph array
185 * into actual glyph indices using ArabicOpenTypeLayoutEngine::mapCharsToGlyps.
186 *
187 * Input paramters:
188 * @param tempGlyphs - the input presentation forms
189 * @param tempCharIndices - the input character index array
190 * @param tempGlyphCount - the number of Presentation Froms
191 *
192 * Output parameters:
193 * @param glyphs - the output glyph index array
194 * @param charIndices - the output character index array
195 * @param success - set to an error code if the operation fails
196 *
197 * @return the number of glyph indices in the output glyph index array
198 *
199 * @internal
200 */
374ca955 201 virtual le_int32 glyphPostProcessing(LEGlyphStorage &tempGlyphStorage, LEGlyphStorage &glyphStorage, LEErrorCode &success);
b75a7d8f
A
202
203 /**
204 * This method copies the input characters into the output glyph index array,
205 * for use by the canned GSUB table. It also generates the character index array.
206 *
207 * Input parameters:
208 * @param chars - the input character context
209 * @param offset - the offset of the first character to be mapped
210 * @param count - the number of characters to be mapped
374ca955
A
211 * @param reverse - if <code>TRUE</code>, the output will be in reverse order
212 * @param mirror - if <code>TRUE</code>, do character mirroring
213 * @param glyphStorage - the glyph storage object. Glyph and char index arrays will be updated.
b75a7d8f 214 *
b75a7d8f
A
215 * @param success - set to an error code if the operation fails
216 *
217 * @internal
218 */
46f4442e 219 virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror,
374ca955 220 LEGlyphStorage &glyphStorage, LEErrorCode &success);
b75a7d8f
A
221
222 /**
223 * This method ensures that all vowel and accent glyphs have a zero advance width by calling
224 * the adjustMarkGlyphs method. The character codes are used to identify the vowel and mark
225 * glyphs.
226 *
227 * @param chars - the input character context
228 * @param offset - the offset of the first character to process
229 * @param count - the number of characters to process
374ca955
A
230 * @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
231 * @param glyphStorage - the glyph storage object. The glyph positions will be updated as needed.
b75a7d8f
A
232 * @param success - output parameter set to an error code if the operation fails
233 *
234 * @internal
235 */
374ca955 236 virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
b75a7d8f
A
237};
238
239U_NAMESPACE_END
240#endif
241