os/textandloc/fontservices/textshaperplugin/IcuSource/layout/ArabicLayoutEngine.h
Update contrib.
4 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
8 #ifndef __ARABICLAYOUTENGINE_H
9 #define __ARABICLAYOUTENGINE_H
12 #include "LEFontInstance.h"
13 #include "LEGlyphFilter.h"
14 #include "LayoutEngine.h"
15 #include "OpenTypeLayoutEngine.h"
17 #include "GlyphSubstitutionTables.h"
18 #include "GlyphDefinitionTables.h"
19 #include "GlyphPositioningTables.h"
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.
31 class ArabicOpenTypeLayoutEngine : public OpenTypeLayoutEngine
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.
40 * @param fontInstance - the font
41 * @param scriptCode - the script
42 * @param langaugeCode - the language
43 * @param gsubTable - the GSUB table
45 * @see LayoutEngine::layoutEngineFactory
46 * @see OpenTypeLayoutEngine
47 * @see ScriptAndLanguageTags.h for script and language codes
51 ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
52 le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
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.
58 * @param fontInstance - the font
59 * @param scriptCode - the script
60 * @param langaugeCode - the language
62 * @see OpenTypeLayoutEngine
63 * @see ScriptAndLanguageTags.h for script and language codes
67 ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
71 * The destructor, virtual for correct polymorphic invocation.
75 virtual ~ArabicOpenTypeLayoutEngine();
78 * ICU "poor man's RTTI", returns a UClassID for the actual class.
82 virtual UClassID getDynamicClassID() const;
85 * ICU "poor man's RTTI", returns a UClassID for this class.
89 static UClassID getStaticClassID();
94 * This method does Arabic OpenType character processing. It assigns the OpenType feature
95 * tags to the characters to generate the correct contextual forms and ligatures.
98 * @param chars - the input character context
99 * @param offset - the index of the first character to process
100 * @param count - the number of characters to process
101 * @param max - the number of characters in the input context
102 * @param rightToLeft - <code>TRUE</code> if the characters are in a right to left directional run
105 * @param outChars - the output character arrayt
106 * @param charIndices - the output character index array
107 * @param featureTags - the output feature tag array
108 * @param success - set to an error code if the operation fails
110 * @return the output character count
114 virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
115 LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
118 * This method applies the GPOS table if it is present, otherwise it ensures that all vowel
119 * and accent glyphs have a zero advance width by calling the adjustMarkGlyphs method.
120 * If the font contains a GDEF table, that is used to identify voewls and accents. Otherwise
121 * the character codes are used.
123 * @param chars - the input character context
124 * @param offset - the offset of the first character to process
125 * @param count - the number of characters to process
126 * @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
127 * @param glyphs - the input glyph array
128 * @param glyphCount - the number of glyphs
129 * @param positions - the position array, will be updated as needed
130 * @param success - output parameter set to an error code if the operation fails
134 virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
136 // static void adjustMarkGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success);
141 * The class implements OpenType layout for Arabic fonts which don't
142 * contain a GSUB table, using a canned GSUB table based on Unicode
143 * Arabic Presentation Forms. It overrides the mapCharsToGlyphs method
144 * to use the Presentation Forms as logical glyph indices. It overrides the
145 * glyphPostProcessing method to convert the Presentation Forms to actual
148 * @see ArabicOpenTypeLayoutEngine
152 class UnicodeArabicOpenTypeLayoutEngine : public ArabicOpenTypeLayoutEngine
156 * This constructs an instance of UnicodeArabicOpenTypeLayoutEngine for a specific font,
157 * script and language.
159 * @param fontInstance - the font
160 * @param scriptCode - the script
161 * @param languageCode - the language
163 * @see LEFontInstance
164 * @see ScriptAndLanguageTags.h for script and language codes
168 UnicodeArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
172 * The destructor, virtual for correct polymorphic invocation.
176 virtual ~UnicodeArabicOpenTypeLayoutEngine();
181 * This method converts the Arabic Presentation Forms in the temp glyph array
182 * into actual glyph indices using ArabicOpenTypeLayoutEngine::mapCharsToGlyps.
185 * @param tempGlyphs - the input presentation forms
186 * @param tempCharIndices - the input character index array
187 * @param tempGlyphCount - the number of Presentation Froms
190 * @param glyphs - the output glyph index array
191 * @param charIndices - the output character index array
192 * @param success - set to an error code if the operation fails
194 * @return the number of glyph indices in the output glyph index array
198 virtual le_int32 glyphPostProcessing(LEGlyphStorage &tempGlyphStorage, LEGlyphStorage &glyphStorage, LEErrorCode &success);
201 * This method copies the input characters into the output glyph index array,
202 * for use by the canned GSUB table. It also generates the character index array.
205 * @param chars - the input character context
206 * @param offset - the offset of the first character to be mapped
207 * @param count - the number of characters to be mapped
208 * @param reverse - if <code>TRUE</code>, the output will be in reverse order
209 * @param mirror - if <code>TRUE</code>, do character mirroring
210 * @param glyphStorage - the glyph storage object. Glyph and char index arrays will be updated.
212 * @param success - set to an error code if the operation fails
216 virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror,
217 LEGlyphStorage &glyphStorage, LEErrorCode &success);
220 * This method ensures that all vowel and accent glyphs have a zero advance width by calling
221 * the adjustMarkGlyphs method. The character codes are used to identify the vowel and mark
224 * @param chars - the input character context
225 * @param offset - the offset of the first character to process
226 * @param count - the number of characters to process
227 * @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
228 * @param glyphStorage - the glyph storage object. The glyph positions will be updated as needed.
229 * @param success - output parameter set to an error code if the operation fails
233 virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);