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