sl@0:
sl@0: /*
sl@0: *
sl@0: * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
sl@0: *
sl@0: */
sl@0:
sl@0: #ifndef __ARABICLAYOUTENGINE_H
sl@0: #define __ARABICLAYOUTENGINE_H
sl@0:
sl@0: #include "LETypes.h"
sl@0: #include "LEFontInstance.h"
sl@0: #include "LEGlyphFilter.h"
sl@0: #include "LayoutEngine.h"
sl@0: #include "OpenTypeLayoutEngine.h"
sl@0:
sl@0: #include "GlyphSubstitutionTables.h"
sl@0: #include "GlyphDefinitionTables.h"
sl@0: #include "GlyphPositioningTables.h"
sl@0:
sl@0: U_NAMESPACE_BEGIN
sl@0:
sl@0: /**
sl@0: * This class implements OpenType layout for Arabic fonts. It overrides
sl@0: * the characerProcessing method to assign the correct OpenType feature
sl@0: * tags for the Arabic contextual forms. It also overrides the adjustGlyphPositions
sl@0: * method to guarantee that all vowel and accent glyphs have zero advance width.
sl@0: *
sl@0: * @internal
sl@0: */
sl@0: class ArabicOpenTypeLayoutEngine : public OpenTypeLayoutEngine
sl@0: {
sl@0: public:
sl@0: /**
sl@0: * This is the main constructor. It constructs an instance of ArabicOpenTypeLayoutEngine for
sl@0: * a particular font, script and language. It takes the GSUB table as a parameter since
sl@0: * LayoutEngine::layoutEngineFactory has to read the GSUB table to know that it has an
sl@0: * Indic OpenType font.
sl@0: *
sl@0: * @param fontInstance - the font
sl@0: * @param scriptCode - the script
sl@0: * @param langaugeCode - the language
sl@0: * @param gsubTable - the GSUB table
sl@0: *
sl@0: * @see LayoutEngine::layoutEngineFactory
sl@0: * @see OpenTypeLayoutEngine
sl@0: * @see ScriptAndLanguageTags.h for script and language codes
sl@0: *
sl@0: * @internal
sl@0: */
sl@0: ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
sl@0: le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
sl@0:
sl@0: /**
sl@0: * This constructor is used when the font requires a "canned" GSUB table which can't be known
sl@0: * until after this constructor has been invoked.
sl@0: *
sl@0: * @param fontInstance - the font
sl@0: * @param scriptCode - the script
sl@0: * @param langaugeCode - the language
sl@0: *
sl@0: * @see OpenTypeLayoutEngine
sl@0: * @see ScriptAndLanguageTags.h for script and language codes
sl@0: *
sl@0: * @internal
sl@0: */
sl@0: ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
sl@0: le_int32 typoFlags);
sl@0:
sl@0: /**
sl@0: * The destructor, virtual for correct polymorphic invocation.
sl@0: *
sl@0: * @internal
sl@0: */
sl@0: virtual ~ArabicOpenTypeLayoutEngine();
sl@0:
sl@0: /**
sl@0: * ICU "poor man's RTTI", returns a UClassID for the actual class.
sl@0: *
sl@0: * @stable ICU 2.8
sl@0: */
sl@0: virtual UClassID getDynamicClassID() const;
sl@0:
sl@0: /**
sl@0: * ICU "poor man's RTTI", returns a UClassID for this class.
sl@0: *
sl@0: * @stable ICU 2.8
sl@0: */
sl@0: static UClassID getStaticClassID();
sl@0:
sl@0: protected:
sl@0:
sl@0: /**
sl@0: * This method does Arabic OpenType character processing. It assigns the OpenType feature
sl@0: * tags to the characters to generate the correct contextual forms and ligatures.
sl@0: *
sl@0: * Input parameters:
sl@0: * @param chars - the input character context
sl@0: * @param offset - the index of the first character to process
sl@0: * @param count - the number of characters to process
sl@0: * @param max - the number of characters in the input context
sl@0: * @param rightToLeft - TRUE
if the characters are in a right to left directional run
sl@0: *
sl@0: * Output parameters:
sl@0: * @param outChars - the output character arrayt
sl@0: * @param charIndices - the output character index array
sl@0: * @param featureTags - the output feature tag array
sl@0: * @param success - set to an error code if the operation fails
sl@0: *
sl@0: * @return the output character count
sl@0: *
sl@0: * @internal
sl@0: */
sl@0: virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
sl@0: LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
sl@0:
sl@0: /**
sl@0: * This method applies the GPOS table if it is present, otherwise it ensures that all vowel
sl@0: * and accent glyphs have a zero advance width by calling the adjustMarkGlyphs method.
sl@0: * If the font contains a GDEF table, that is used to identify voewls and accents. Otherwise
sl@0: * the character codes are used.
sl@0: *
sl@0: * @param chars - the input character context
sl@0: * @param offset - the offset of the first character to process
sl@0: * @param count - the number of characters to process
sl@0: * @param reverse - TRUE
if the glyphs in the glyph array have been reordered
sl@0: * @param glyphs - the input glyph array
sl@0: * @param glyphCount - the number of glyphs
sl@0: * @param positions - the position array, will be updated as needed
sl@0: * @param success - output parameter set to an error code if the operation fails
sl@0: *
sl@0: * @internal
sl@0: */
sl@0: virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
sl@0:
sl@0: // static void adjustMarkGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success);
sl@0:
sl@0: };
sl@0:
sl@0: /**
sl@0: * The class implements OpenType layout for Arabic fonts which don't
sl@0: * contain a GSUB table, using a canned GSUB table based on Unicode
sl@0: * Arabic Presentation Forms. It overrides the mapCharsToGlyphs method
sl@0: * to use the Presentation Forms as logical glyph indices. It overrides the
sl@0: * glyphPostProcessing method to convert the Presentation Forms to actual
sl@0: * glyph indices.
sl@0: *
sl@0: * @see ArabicOpenTypeLayoutEngine
sl@0: *
sl@0: * @internal
sl@0: */
sl@0: class UnicodeArabicOpenTypeLayoutEngine : public ArabicOpenTypeLayoutEngine
sl@0: {
sl@0: public:
sl@0: /**
sl@0: * This constructs an instance of UnicodeArabicOpenTypeLayoutEngine for a specific font,
sl@0: * script and language.
sl@0: *
sl@0: * @param fontInstance - the font
sl@0: * @param scriptCode - the script
sl@0: * @param languageCode - the language
sl@0: *
sl@0: * @see LEFontInstance
sl@0: * @see ScriptAndLanguageTags.h for script and language codes
sl@0: *
sl@0: * @internal
sl@0: */
sl@0: UnicodeArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
sl@0: le_int32 typoFlags);
sl@0:
sl@0: /**
sl@0: * The destructor, virtual for correct polymorphic invocation.
sl@0: *
sl@0: * @internal
sl@0: */
sl@0: virtual ~UnicodeArabicOpenTypeLayoutEngine();
sl@0:
sl@0: protected:
sl@0:
sl@0: /**
sl@0: * This method converts the Arabic Presentation Forms in the temp glyph array
sl@0: * into actual glyph indices using ArabicOpenTypeLayoutEngine::mapCharsToGlyps.
sl@0: *
sl@0: * Input paramters:
sl@0: * @param tempGlyphs - the input presentation forms
sl@0: * @param tempCharIndices - the input character index array
sl@0: * @param tempGlyphCount - the number of Presentation Froms
sl@0: *
sl@0: * Output parameters:
sl@0: * @param glyphs - the output glyph index array
sl@0: * @param charIndices - the output character index array
sl@0: * @param success - set to an error code if the operation fails
sl@0: *
sl@0: * @return the number of glyph indices in the output glyph index array
sl@0: *
sl@0: * @internal
sl@0: */
sl@0: virtual le_int32 glyphPostProcessing(LEGlyphStorage &tempGlyphStorage, LEGlyphStorage &glyphStorage, LEErrorCode &success);
sl@0:
sl@0: /**
sl@0: * This method copies the input characters into the output glyph index array,
sl@0: * for use by the canned GSUB table. It also generates the character index array.
sl@0: *
sl@0: * Input parameters:
sl@0: * @param chars - the input character context
sl@0: * @param offset - the offset of the first character to be mapped
sl@0: * @param count - the number of characters to be mapped
sl@0: * @param reverse - if TRUE
, the output will be in reverse order
sl@0: * @param mirror - if TRUE
, do character mirroring
sl@0: * @param glyphStorage - the glyph storage object. Glyph and char index arrays will be updated.
sl@0: *
sl@0: * @param success - set to an error code if the operation fails
sl@0: *
sl@0: * @internal
sl@0: */
sl@0: virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror,
sl@0: LEGlyphStorage &glyphStorage, LEErrorCode &success);
sl@0:
sl@0: /**
sl@0: * This method ensures that all vowel and accent glyphs have a zero advance width by calling
sl@0: * the adjustMarkGlyphs method. The character codes are used to identify the vowel and mark
sl@0: * glyphs.
sl@0: *
sl@0: * @param chars - the input character context
sl@0: * @param offset - the offset of the first character to process
sl@0: * @param count - the number of characters to process
sl@0: * @param reverse - TRUE
if the glyphs in the glyph array have been reordered
sl@0: * @param glyphStorage - the glyph storage object. The glyph positions will be updated as needed.
sl@0: * @param success - output parameter set to an error code if the operation fails
sl@0: *
sl@0: * @internal
sl@0: */
sl@0: virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
sl@0: };
sl@0:
sl@0: U_NAMESPACE_END
sl@0: #endif
sl@0: