4 * (C) Copyright IBM Corp. 1998-2004 - 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 ScriptAndLangaugeTags.h for script and language codes
51 ArabicOpenTypeLayoutEngine(const LEFontInstance
*fontInstance
, le_int32 scriptCode
, le_int32 languageCode
,
52 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 ScriptAndLangaugeTags.h for script and language codes
67 ArabicOpenTypeLayoutEngine(const LEFontInstance
*fontInstance
, le_int32 scriptCode
, le_int32 languageCode
);
70 * The destructor, virtual for correct polymorphic invocation.
74 virtual ~ArabicOpenTypeLayoutEngine();
77 * ICU "poor man's RTTI", returns a UClassID for the actual class.
81 virtual UClassID
getDynamicClassID() const;
84 * ICU "poor man's RTTI", returns a UClassID for this class.
88 static UClassID
getStaticClassID();
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.
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
101 * @param rightToLeft - <code>TRUE</code> if the characters are in a right to left directional run
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
109 * @return the output character count
113 virtual le_int32
characterProcessing(const LEUnicode chars
[], le_int32 offset
, le_int32 count
, le_int32 max
, le_bool rightToLeft
,
114 LEUnicode
*&outChars
, LEGlyphStorage
&glyphStorage
, LEErrorCode
&success
);
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.
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
125 * @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
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
133 virtual void adjustGlyphPositions(const LEUnicode chars
[], le_int32 offset
, le_int32 count
, le_bool reverse
, LEGlyphStorage
&glyphStorage
, LEErrorCode
&success
);
135 // static void adjustMarkGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success);
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
147 * @see ArabicOpenTypeLayoutEngine
151 class UnicodeArabicOpenTypeLayoutEngine
: public ArabicOpenTypeLayoutEngine
155 * This constructs an instance of UnicodeArabicOpenTypeLayoutEngine for a specific font,
156 * script and language.
158 * @param fontInstance - the font
159 * @param scriptCode - the script
160 * @param languageCode - the language
162 * @see LEFontInstance
163 * @see ScriptAndLanguageTags.h for script and language codes
167 UnicodeArabicOpenTypeLayoutEngine(const LEFontInstance
*fontInstance
, le_int32 scriptCode
, le_int32 languageCode
);
170 * The destructor, virtual for correct polymorphic invocation.
174 virtual ~UnicodeArabicOpenTypeLayoutEngine();
179 * This method converts the Arabic Presentation Forms in the temp glyph array
180 * into actual glyph indices using ArabicOpenTypeLayoutEngine::mapCharsToGlyps.
183 * @param tempGlyphs - the input presentation forms
184 * @param tempCharIndices - the input character index array
185 * @param tempGlyphCount - the number of Presentation Froms
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
192 * @return the number of glyph indices in the output glyph index array
196 virtual le_int32
glyphPostProcessing(LEGlyphStorage
&tempGlyphStorage
, LEGlyphStorage
&glyphStorage
, LEErrorCode
&success
);
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.
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
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.
210 * @param success - set to an error code if the operation fails
214 virtual void mapCharsToGlyphs(const LEUnicode chars
[], le_int32 offset
, le_int32 count
, le_bool reverse
, le_bool mirror
,
215 LEGlyphStorage
&glyphStorage
, LEErrorCode
&success
);
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
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
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.
227 * @param success - output parameter set to an error code if the operation fails
231 virtual void adjustGlyphPositions(const LEUnicode chars
[], le_int32 offset
, le_int32 count
, le_bool reverse
, LEGlyphStorage
&glyphStorage
, LEErrorCode
&success
);