4 * (C) Copyright IBM Corp. 1998-2013 - 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
44 * @param success - set to an error code if the operation fails
46 * @see LayoutEngine::layoutEngineFactory
47 * @see OpenTypeLayoutEngine
48 * @see ScriptAndLanguageTags.h for script and language codes
52 ArabicOpenTypeLayoutEngine(const LEFontInstance
*fontInstance
, le_int32 scriptCode
, le_int32 languageCode
,
53 le_int32 typoFlags
, const LEReferenceTo
<GlyphSubstitutionTableHeader
> &gsubTable
, LEErrorCode
&success
);
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.
59 * @param fontInstance - the font
60 * @param scriptCode - the script
61 * @param langaugeCode - the language
62 * @param success - set to an error code if the operation fails
64 * @see OpenTypeLayoutEngine
65 * @see ScriptAndLanguageTags.h for script and language codes
69 ArabicOpenTypeLayoutEngine(const LEFontInstance
*fontInstance
, le_int32 scriptCode
, le_int32 languageCode
,
70 le_int32 typoFlags
, LEErrorCode
&success
);
73 * The destructor, virtual for correct polymorphic invocation.
77 virtual ~ArabicOpenTypeLayoutEngine();
80 * ICU "poor man's RTTI", returns a UClassID for the actual class.
84 virtual UClassID
getDynamicClassID() const;
87 * ICU "poor man's RTTI", returns a UClassID for this class.
91 static UClassID
getStaticClassID();
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.
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
104 * @param rightToLeft - <code>TRUE</code> if the characters are in a right to left directional run
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
112 * @return the output character count
116 virtual le_int32
characterProcessing(const LEUnicode chars
[], le_int32 offset
, le_int32 count
, le_int32 max
, le_bool rightToLeft
,
117 LEUnicode
*&outChars
, LEGlyphStorage
&glyphStorage
, LEErrorCode
&success
);
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.
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
128 * @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
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
136 virtual void adjustGlyphPositions(const LEUnicode chars
[], le_int32 offset
, le_int32 count
, le_bool reverse
, LEGlyphStorage
&glyphStorage
, LEErrorCode
&success
);
138 // static void adjustMarkGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success);
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
150 * @see ArabicOpenTypeLayoutEngine
154 class UnicodeArabicOpenTypeLayoutEngine
: public ArabicOpenTypeLayoutEngine
158 * This constructs an instance of UnicodeArabicOpenTypeLayoutEngine for a specific font,
159 * script and language.
161 * @param fontInstance - the font
162 * @param scriptCode - the script
163 * @param languageCode - the language
164 * @param success - set to an error code if the operation fails
166 * @see LEFontInstance
167 * @see ScriptAndLanguageTags.h for script and language codes
171 UnicodeArabicOpenTypeLayoutEngine(const LEFontInstance
*fontInstance
, le_int32 scriptCode
, le_int32 languageCode
,
172 le_int32 typoFlags
, LEErrorCode
&success
);
175 * The destructor, virtual for correct polymorphic invocation.
179 virtual ~UnicodeArabicOpenTypeLayoutEngine();
184 * This method converts the Arabic Presentation Forms in the temp glyph array
185 * into actual glyph indices using ArabicOpenTypeLayoutEngine::mapCharsToGlyps.
188 * @param tempGlyphs - the input presentation forms
189 * @param tempCharIndices - the input character index array
190 * @param tempGlyphCount - the number of Presentation Froms
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
197 * @return the number of glyph indices in the output glyph index array
201 virtual le_int32
glyphPostProcessing(LEGlyphStorage
&tempGlyphStorage
, LEGlyphStorage
&glyphStorage
, LEErrorCode
&success
);
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.
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
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.
215 * @param success - set to an error code if the operation fails
219 virtual void mapCharsToGlyphs(const LEUnicode chars
[], le_int32 offset
, le_int32 count
, le_bool reverse
, le_bool mirror
,
220 LEGlyphStorage
&glyphStorage
, LEErrorCode
&success
);
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
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
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.
232 * @param success - output parameter set to an error code if the operation fails
236 virtual void adjustGlyphPositions(const LEUnicode chars
[], le_int32 offset
, le_int32 count
, le_bool reverse
, LEGlyphStorage
&glyphStorage
, LEErrorCode
&success
);