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