os/textandloc/fontservices/textshaperplugin/IcuSource/layout/ArabicLayoutEngine.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/layout/ArabicLayoutEngine.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,238 @@
     1.4 +
     1.5 +/*
     1.6 + *
     1.7 + * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
     1.8 + *
     1.9 + */
    1.10 +
    1.11 +#ifndef __ARABICLAYOUTENGINE_H
    1.12 +#define __ARABICLAYOUTENGINE_H
    1.13 +
    1.14 +#include "LETypes.h"
    1.15 +#include "LEFontInstance.h"
    1.16 +#include "LEGlyphFilter.h"
    1.17 +#include "LayoutEngine.h"
    1.18 +#include "OpenTypeLayoutEngine.h"
    1.19 +
    1.20 +#include "GlyphSubstitutionTables.h"
    1.21 +#include "GlyphDefinitionTables.h"
    1.22 +#include "GlyphPositioningTables.h"
    1.23 +
    1.24 +U_NAMESPACE_BEGIN
    1.25 +
    1.26 +/**
    1.27 + * This class implements OpenType layout for Arabic fonts. It overrides
    1.28 + * the characerProcessing method to assign the correct OpenType feature
    1.29 + * tags for the Arabic contextual forms. It also overrides the adjustGlyphPositions
    1.30 + * method to guarantee that all vowel and accent glyphs have zero advance width.
    1.31 + *
    1.32 + * @internal
    1.33 + */
    1.34 +class ArabicOpenTypeLayoutEngine : public OpenTypeLayoutEngine
    1.35 +{
    1.36 +public:
    1.37 +    /**
    1.38 +     * This is the main constructor. It constructs an instance of ArabicOpenTypeLayoutEngine for
    1.39 +     * a particular font, script and language. It takes the GSUB table as a parameter since
    1.40 +     * LayoutEngine::layoutEngineFactory has to read the GSUB table to know that it has an
    1.41 +     * Indic OpenType font.
    1.42 +     *
    1.43 +     * @param fontInstance - the font
    1.44 +     * @param scriptCode - the script
    1.45 +     * @param langaugeCode - the language
    1.46 +     * @param gsubTable - the GSUB table
    1.47 +     *
    1.48 +     * @see LayoutEngine::layoutEngineFactory
    1.49 +     * @see OpenTypeLayoutEngine
    1.50 +     * @see ScriptAndLanguageTags.h for script and language codes
    1.51 +     *
    1.52 +     * @internal
    1.53 +     */
    1.54 +    ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
    1.55 +                            le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
    1.56 +
    1.57 +    /**
    1.58 +     * This constructor is used when the font requires a "canned" GSUB table which can't be known
    1.59 +     * until after this constructor has been invoked.
    1.60 +     *
    1.61 +     * @param fontInstance - the font
    1.62 +     * @param scriptCode - the script
    1.63 +     * @param langaugeCode - the language
    1.64 +     *
    1.65 +     * @see OpenTypeLayoutEngine
    1.66 +     * @see ScriptAndLanguageTags.h for script and language codes
    1.67 +     *
    1.68 +     * @internal
    1.69 +     */
    1.70 +    ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
    1.71 +			       le_int32 typoFlags);
    1.72 +
    1.73 +    /**
    1.74 +     * The destructor, virtual for correct polymorphic invocation.
    1.75 +     *
    1.76 +     * @internal
    1.77 +     */
    1.78 +    virtual ~ArabicOpenTypeLayoutEngine();
    1.79 +
    1.80 +    /**
    1.81 +     * ICU "poor man's RTTI", returns a UClassID for the actual class.
    1.82 +     *
    1.83 +     * @stable ICU 2.8
    1.84 +     */
    1.85 +    virtual UClassID getDynamicClassID() const;
    1.86 +
    1.87 +    /**
    1.88 +     * ICU "poor man's RTTI", returns a UClassID for this class.
    1.89 +     *
    1.90 +     * @stable ICU 2.8
    1.91 +     */
    1.92 +    static UClassID getStaticClassID();
    1.93 +
    1.94 +protected:
    1.95 +
    1.96 +    /**
    1.97 +     * This method does Arabic OpenType character processing. It assigns the OpenType feature
    1.98 +     * tags to the characters to generate the correct contextual forms and ligatures.
    1.99 +     *
   1.100 +     * Input parameters:
   1.101 +     * @param chars - the input character context
   1.102 +     * @param offset - the index of the first character to process
   1.103 +     * @param count - the number of characters to process
   1.104 +     * @param max - the number of characters in the input context
   1.105 +     * @param rightToLeft - <code>TRUE</code> if the characters are in a right to left directional run
   1.106 +     *
   1.107 +     * Output parameters:
   1.108 +     * @param outChars - the output character arrayt
   1.109 +     * @param charIndices - the output character index array
   1.110 +     * @param featureTags - the output feature tag array
   1.111 +     * @param success - set to an error code if the operation fails
   1.112 +     *
   1.113 +     * @return the output character count
   1.114 +     *
   1.115 +     * @internal
   1.116 +     */
   1.117 +    virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
   1.118 +            LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
   1.119 +
   1.120 +    /**
   1.121 +     * This method applies the GPOS table if it is present, otherwise it ensures that all vowel
   1.122 +     * and accent glyphs have a zero advance width by calling the adjustMarkGlyphs method.
   1.123 +     * If the font contains a GDEF table, that is used to identify voewls and accents. Otherwise
   1.124 +     * the character codes are used.
   1.125 +     *
   1.126 +     * @param chars - the input character context
   1.127 +     * @param offset - the offset of the first character to process
   1.128 +     * @param count - the number of characters to process
   1.129 +     * @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
   1.130 +     * @param glyphs - the input glyph array
   1.131 +     * @param glyphCount - the number of glyphs
   1.132 +     * @param positions - the position array, will be updated as needed
   1.133 +     * @param success - output parameter set to an error code if the operation fails
   1.134 +     *
   1.135 +     * @internal
   1.136 +     */
   1.137 +    virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
   1.138 +
   1.139 +    // static void adjustMarkGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success);
   1.140 +
   1.141 +};
   1.142 +
   1.143 +/**
   1.144 + * The class implements OpenType layout for Arabic fonts which don't
   1.145 + * contain a GSUB table, using a canned GSUB table based on Unicode
   1.146 + * Arabic Presentation Forms. It overrides the mapCharsToGlyphs method
   1.147 + * to use the Presentation Forms as logical glyph indices. It overrides the
   1.148 + * glyphPostProcessing method to convert the Presentation Forms to actual
   1.149 + * glyph indices.
   1.150 + *
   1.151 + * @see ArabicOpenTypeLayoutEngine
   1.152 + *
   1.153 + * @internal
   1.154 + */
   1.155 +class UnicodeArabicOpenTypeLayoutEngine : public ArabicOpenTypeLayoutEngine
   1.156 +{
   1.157 +public:
   1.158 +    /**
   1.159 +     * This constructs an instance of UnicodeArabicOpenTypeLayoutEngine for a specific font,
   1.160 +     * script and language.
   1.161 +     *
   1.162 +     * @param fontInstance - the font
   1.163 +     * @param scriptCode - the script
   1.164 +     * @param languageCode - the language
   1.165 +     *
   1.166 +     * @see LEFontInstance
   1.167 +     * @see ScriptAndLanguageTags.h for script and language codes
   1.168 +     *
   1.169 +     * @internal
   1.170 +     */
   1.171 +    UnicodeArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
   1.172 +		le_int32 typoFlags);
   1.173 +
   1.174 +    /**
   1.175 +     * The destructor, virtual for correct polymorphic invocation.
   1.176 +     *
   1.177 +     * @internal
   1.178 +     */
   1.179 +    virtual ~UnicodeArabicOpenTypeLayoutEngine();
   1.180 +
   1.181 +protected:
   1.182 +
   1.183 +    /**
   1.184 +     * This method converts the Arabic Presentation Forms in the temp glyph array
   1.185 +     * into actual glyph indices using ArabicOpenTypeLayoutEngine::mapCharsToGlyps.
   1.186 +     *
   1.187 +     * Input paramters:
   1.188 +     * @param tempGlyphs - the input presentation forms
   1.189 +     * @param tempCharIndices - the input character index array
   1.190 +     * @param tempGlyphCount - the number of Presentation Froms
   1.191 +     *
   1.192 +     * Output parameters:
   1.193 +     * @param glyphs - the output glyph index array
   1.194 +     * @param charIndices - the output character index array
   1.195 +     * @param success - set to an error code if the operation fails
   1.196 +     *
   1.197 +     * @return the number of glyph indices in the output glyph index array
   1.198 +     *
   1.199 +     * @internal
   1.200 +     */
   1.201 +    virtual le_int32 glyphPostProcessing(LEGlyphStorage &tempGlyphStorage, LEGlyphStorage &glyphStorage, LEErrorCode &success);
   1.202 +
   1.203 +    /**
   1.204 +     * This method copies the input characters into the output glyph index array,
   1.205 +     * for use by the canned GSUB table. It also generates the character index array.
   1.206 +     *
   1.207 +     * Input parameters:
   1.208 +     * @param chars - the input character context
   1.209 +     * @param offset - the offset of the first character to be mapped
   1.210 +     * @param count - the number of characters to be mapped
   1.211 +     * @param reverse - if <code>TRUE</code>, the output will be in reverse order
   1.212 +     * @param mirror - if <code>TRUE</code>, do character mirroring
   1.213 +     * @param glyphStorage - the glyph storage object. Glyph and char index arrays will be updated.
   1.214 +     *
   1.215 +     * @param success - set to an error code if the operation fails
   1.216 +     *
   1.217 +     * @internal
   1.218 +     */
   1.219 +    virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror,
   1.220 +        LEGlyphStorage &glyphStorage, LEErrorCode &success);
   1.221 +
   1.222 +    /**
   1.223 +     * This method ensures that all vowel and accent glyphs have a zero advance width by calling
   1.224 +     * the adjustMarkGlyphs method. The character codes are used to identify the vowel and mark
   1.225 +     * glyphs.
   1.226 +     *
   1.227 +     * @param chars - the input character context
   1.228 +     * @param offset - the offset of the first character to process
   1.229 +     * @param count - the number of characters to process
   1.230 +     * @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
   1.231 +     * @param glyphStorage - the glyph storage object. The glyph positions will be updated as needed.
   1.232 +     * @param success - output parameter set to an error code if the operation fails
   1.233 +     *
   1.234 +     * @internal
   1.235 +     */
   1.236 +    virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
   1.237 +};
   1.238 +
   1.239 +U_NAMESPACE_END
   1.240 +#endif
   1.241 +