os/textandloc/fontservices/textshaperplugin/IcuSource/layout/ArabicLayoutEngine.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
sl@0
     2
/*
sl@0
     3
 *
sl@0
     4
 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
sl@0
     5
 *
sl@0
     6
 */
sl@0
     7
sl@0
     8
#ifndef __ARABICLAYOUTENGINE_H
sl@0
     9
#define __ARABICLAYOUTENGINE_H
sl@0
    10
sl@0
    11
#include "LETypes.h"
sl@0
    12
#include "LEFontInstance.h"
sl@0
    13
#include "LEGlyphFilter.h"
sl@0
    14
#include "LayoutEngine.h"
sl@0
    15
#include "OpenTypeLayoutEngine.h"
sl@0
    16
sl@0
    17
#include "GlyphSubstitutionTables.h"
sl@0
    18
#include "GlyphDefinitionTables.h"
sl@0
    19
#include "GlyphPositioningTables.h"
sl@0
    20
sl@0
    21
U_NAMESPACE_BEGIN
sl@0
    22
sl@0
    23
/**
sl@0
    24
 * This class implements OpenType layout for Arabic fonts. It overrides
sl@0
    25
 * the characerProcessing method to assign the correct OpenType feature
sl@0
    26
 * tags for the Arabic contextual forms. It also overrides the adjustGlyphPositions
sl@0
    27
 * method to guarantee that all vowel and accent glyphs have zero advance width.
sl@0
    28
 *
sl@0
    29
 * @internal
sl@0
    30
 */
sl@0
    31
class ArabicOpenTypeLayoutEngine : public OpenTypeLayoutEngine
sl@0
    32
{
sl@0
    33
public:
sl@0
    34
    /**
sl@0
    35
     * This is the main constructor. It constructs an instance of ArabicOpenTypeLayoutEngine for
sl@0
    36
     * a particular font, script and language. It takes the GSUB table as a parameter since
sl@0
    37
     * LayoutEngine::layoutEngineFactory has to read the GSUB table to know that it has an
sl@0
    38
     * Indic OpenType font.
sl@0
    39
     *
sl@0
    40
     * @param fontInstance - the font
sl@0
    41
     * @param scriptCode - the script
sl@0
    42
     * @param langaugeCode - the language
sl@0
    43
     * @param gsubTable - the GSUB table
sl@0
    44
     *
sl@0
    45
     * @see LayoutEngine::layoutEngineFactory
sl@0
    46
     * @see OpenTypeLayoutEngine
sl@0
    47
     * @see ScriptAndLanguageTags.h for script and language codes
sl@0
    48
     *
sl@0
    49
     * @internal
sl@0
    50
     */
sl@0
    51
    ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
sl@0
    52
                            le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable);
sl@0
    53
sl@0
    54
    /**
sl@0
    55
     * This constructor is used when the font requires a "canned" GSUB table which can't be known
sl@0
    56
     * until after this constructor has been invoked.
sl@0
    57
     *
sl@0
    58
     * @param fontInstance - the font
sl@0
    59
     * @param scriptCode - the script
sl@0
    60
     * @param langaugeCode - the language
sl@0
    61
     *
sl@0
    62
     * @see OpenTypeLayoutEngine
sl@0
    63
     * @see ScriptAndLanguageTags.h for script and language codes
sl@0
    64
     *
sl@0
    65
     * @internal
sl@0
    66
     */
sl@0
    67
    ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
sl@0
    68
			       le_int32 typoFlags);
sl@0
    69
sl@0
    70
    /**
sl@0
    71
     * The destructor, virtual for correct polymorphic invocation.
sl@0
    72
     *
sl@0
    73
     * @internal
sl@0
    74
     */
sl@0
    75
    virtual ~ArabicOpenTypeLayoutEngine();
sl@0
    76
sl@0
    77
    /**
sl@0
    78
     * ICU "poor man's RTTI", returns a UClassID for the actual class.
sl@0
    79
     *
sl@0
    80
     * @stable ICU 2.8
sl@0
    81
     */
sl@0
    82
    virtual UClassID getDynamicClassID() const;
sl@0
    83
sl@0
    84
    /**
sl@0
    85
     * ICU "poor man's RTTI", returns a UClassID for this class.
sl@0
    86
     *
sl@0
    87
     * @stable ICU 2.8
sl@0
    88
     */
sl@0
    89
    static UClassID getStaticClassID();
sl@0
    90
sl@0
    91
protected:
sl@0
    92
sl@0
    93
    /**
sl@0
    94
     * This method does Arabic OpenType character processing. It assigns the OpenType feature
sl@0
    95
     * tags to the characters to generate the correct contextual forms and ligatures.
sl@0
    96
     *
sl@0
    97
     * Input parameters:
sl@0
    98
     * @param chars - the input character context
sl@0
    99
     * @param offset - the index of the first character to process
sl@0
   100
     * @param count - the number of characters to process
sl@0
   101
     * @param max - the number of characters in the input context
sl@0
   102
     * @param rightToLeft - <code>TRUE</code> if the characters are in a right to left directional run
sl@0
   103
     *
sl@0
   104
     * Output parameters:
sl@0
   105
     * @param outChars - the output character arrayt
sl@0
   106
     * @param charIndices - the output character index array
sl@0
   107
     * @param featureTags - the output feature tag array
sl@0
   108
     * @param success - set to an error code if the operation fails
sl@0
   109
     *
sl@0
   110
     * @return the output character count
sl@0
   111
     *
sl@0
   112
     * @internal
sl@0
   113
     */
sl@0
   114
    virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
sl@0
   115
            LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
sl@0
   116
sl@0
   117
    /**
sl@0
   118
     * This method applies the GPOS table if it is present, otherwise it ensures that all vowel
sl@0
   119
     * and accent glyphs have a zero advance width by calling the adjustMarkGlyphs method.
sl@0
   120
     * If the font contains a GDEF table, that is used to identify voewls and accents. Otherwise
sl@0
   121
     * the character codes are used.
sl@0
   122
     *
sl@0
   123
     * @param chars - the input character context
sl@0
   124
     * @param offset - the offset of the first character to process
sl@0
   125
     * @param count - the number of characters to process
sl@0
   126
     * @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
sl@0
   127
     * @param glyphs - the input glyph array
sl@0
   128
     * @param glyphCount - the number of glyphs
sl@0
   129
     * @param positions - the position array, will be updated as needed
sl@0
   130
     * @param success - output parameter set to an error code if the operation fails
sl@0
   131
     *
sl@0
   132
     * @internal
sl@0
   133
     */
sl@0
   134
    virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
sl@0
   135
sl@0
   136
    // static void adjustMarkGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success);
sl@0
   137
sl@0
   138
};
sl@0
   139
sl@0
   140
/**
sl@0
   141
 * The class implements OpenType layout for Arabic fonts which don't
sl@0
   142
 * contain a GSUB table, using a canned GSUB table based on Unicode
sl@0
   143
 * Arabic Presentation Forms. It overrides the mapCharsToGlyphs method
sl@0
   144
 * to use the Presentation Forms as logical glyph indices. It overrides the
sl@0
   145
 * glyphPostProcessing method to convert the Presentation Forms to actual
sl@0
   146
 * glyph indices.
sl@0
   147
 *
sl@0
   148
 * @see ArabicOpenTypeLayoutEngine
sl@0
   149
 *
sl@0
   150
 * @internal
sl@0
   151
 */
sl@0
   152
class UnicodeArabicOpenTypeLayoutEngine : public ArabicOpenTypeLayoutEngine
sl@0
   153
{
sl@0
   154
public:
sl@0
   155
    /**
sl@0
   156
     * This constructs an instance of UnicodeArabicOpenTypeLayoutEngine for a specific font,
sl@0
   157
     * script and language.
sl@0
   158
     *
sl@0
   159
     * @param fontInstance - the font
sl@0
   160
     * @param scriptCode - the script
sl@0
   161
     * @param languageCode - the language
sl@0
   162
     *
sl@0
   163
     * @see LEFontInstance
sl@0
   164
     * @see ScriptAndLanguageTags.h for script and language codes
sl@0
   165
     *
sl@0
   166
     * @internal
sl@0
   167
     */
sl@0
   168
    UnicodeArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
sl@0
   169
		le_int32 typoFlags);
sl@0
   170
sl@0
   171
    /**
sl@0
   172
     * The destructor, virtual for correct polymorphic invocation.
sl@0
   173
     *
sl@0
   174
     * @internal
sl@0
   175
     */
sl@0
   176
    virtual ~UnicodeArabicOpenTypeLayoutEngine();
sl@0
   177
sl@0
   178
protected:
sl@0
   179
sl@0
   180
    /**
sl@0
   181
     * This method converts the Arabic Presentation Forms in the temp glyph array
sl@0
   182
     * into actual glyph indices using ArabicOpenTypeLayoutEngine::mapCharsToGlyps.
sl@0
   183
     *
sl@0
   184
     * Input paramters:
sl@0
   185
     * @param tempGlyphs - the input presentation forms
sl@0
   186
     * @param tempCharIndices - the input character index array
sl@0
   187
     * @param tempGlyphCount - the number of Presentation Froms
sl@0
   188
     *
sl@0
   189
     * Output parameters:
sl@0
   190
     * @param glyphs - the output glyph index array
sl@0
   191
     * @param charIndices - the output character index array
sl@0
   192
     * @param success - set to an error code if the operation fails
sl@0
   193
     *
sl@0
   194
     * @return the number of glyph indices in the output glyph index array
sl@0
   195
     *
sl@0
   196
     * @internal
sl@0
   197
     */
sl@0
   198
    virtual le_int32 glyphPostProcessing(LEGlyphStorage &tempGlyphStorage, LEGlyphStorage &glyphStorage, LEErrorCode &success);
sl@0
   199
sl@0
   200
    /**
sl@0
   201
     * This method copies the input characters into the output glyph index array,
sl@0
   202
     * for use by the canned GSUB table. It also generates the character index array.
sl@0
   203
     *
sl@0
   204
     * Input parameters:
sl@0
   205
     * @param chars - the input character context
sl@0
   206
     * @param offset - the offset of the first character to be mapped
sl@0
   207
     * @param count - the number of characters to be mapped
sl@0
   208
     * @param reverse - if <code>TRUE</code>, the output will be in reverse order
sl@0
   209
     * @param mirror - if <code>TRUE</code>, do character mirroring
sl@0
   210
     * @param glyphStorage - the glyph storage object. Glyph and char index arrays will be updated.
sl@0
   211
     *
sl@0
   212
     * @param success - set to an error code if the operation fails
sl@0
   213
     *
sl@0
   214
     * @internal
sl@0
   215
     */
sl@0
   216
    virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror,
sl@0
   217
        LEGlyphStorage &glyphStorage, LEErrorCode &success);
sl@0
   218
sl@0
   219
    /**
sl@0
   220
     * This method ensures that all vowel and accent glyphs have a zero advance width by calling
sl@0
   221
     * the adjustMarkGlyphs method. The character codes are used to identify the vowel and mark
sl@0
   222
     * glyphs.
sl@0
   223
     *
sl@0
   224
     * @param chars - the input character context
sl@0
   225
     * @param offset - the offset of the first character to process
sl@0
   226
     * @param count - the number of characters to process
sl@0
   227
     * @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered
sl@0
   228
     * @param glyphStorage - the glyph storage object. The glyph positions will be updated as needed.
sl@0
   229
     * @param success - output parameter set to an error code if the operation fails
sl@0
   230
     *
sl@0
   231
     * @internal
sl@0
   232
     */
sl@0
   233
    virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);
sl@0
   234
};
sl@0
   235
sl@0
   236
U_NAMESPACE_END
sl@0
   237
#endif
sl@0
   238