X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b75a7d8f3b4adbae880cab104ce2c6a50eee4db2..ef6cf650f4a75c3f97de06b51fa104f2069b9ea2:/icuSources/layout/OpenTypeLayoutEngine.h diff --git a/icuSources/layout/OpenTypeLayoutEngine.h b/icuSources/layout/OpenTypeLayoutEngine.h index de237baa..0f93ccb9 100644 --- a/icuSources/layout/OpenTypeLayoutEngine.h +++ b/icuSources/layout/OpenTypeLayoutEngine.h @@ -1,8 +1,5 @@ - /* - * %W% %E% - * - * (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved + * (C) Copyright IBM Corp. 1998-2014 - All Rights Reserved * */ @@ -13,6 +10,7 @@ #include "LEGlyphFilter.h" #include "LEFontInstance.h" #include "LayoutEngine.h" +#include "LETableReference.h" #include "GlyphSubstitutionTables.h" #include "GlyphDefinitionTables.h" @@ -45,7 +43,7 @@ U_NAMESPACE_BEGIN * * @internal */ -class OpenTypeLayoutEngine : public LayoutEngine +class U_LAYOUT_API OpenTypeLayoutEngine : public LayoutEngine { public: /** @@ -58,6 +56,7 @@ public: * @param scriptCode - the script * @param langaugeCode - the language * @param gsubTable - the GSUB table + * @param success - set to an error code if the operation fails * * @see LayoutEngine::layoutEngineFactory * @see ScriptAndLangaugeTags.h for script and language codes @@ -65,7 +64,7 @@ public: * @internal */ OpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, - const GlyphSubstitutionTableHeader *gsubTable); + le_int32 typoFlags, const LEReferenceTo &gsubTable, LEErrorCode &success); /** * This constructor is used when the font requires a "canned" GSUB table which can't be known @@ -74,10 +73,12 @@ public: * @param fontInstance - the font * @param scriptCode - the script * @param langaugeCode - the language + * @param success - set to an error code if the operation fails * * @internal */ - OpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode); + OpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, + le_int32 typoFlags, LEErrorCode &success); /** * The destructor, virtual for correct polymorphic invocation. @@ -89,6 +90,8 @@ public: /** * A convenience method used to convert the script code into * the four byte script tag required by OpenType. + * For Indic languages where multiple script tags exist, + * the version 1 (old style) tag is returned. * * @param scriptCode - the script code * @@ -97,6 +100,19 @@ public: * @internal */ static LETag getScriptTag(le_int32 scriptCode); + /** + * A convenience method used to convert the script code into + * the four byte script tag required by OpenType. + * For Indic languages where multiple script tags exist, + * the version 2 tag is returned. + * + * @param scriptCode - the script code + * + * @return the four byte script tag + * + * @internal + */ + static LETag getV2ScriptTag(le_int32 scriptCode); /** * A convenience method used to convert the langauge code into @@ -113,16 +129,23 @@ public: /** * ICU "poor man's RTTI", returns a UClassID for the actual class. * - * @draft ICU 2.2 + * @deprecated ICU 54. See {@link icu::LayoutEngine} */ - virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } + virtual UClassID getDynamicClassID() const; /** * ICU "poor man's RTTI", returns a UClassID for this class. * - * @draft ICU 2.2 + * @deprecated ICU 54. See {@link icu::LayoutEngine} + */ + static UClassID getStaticClassID(); + + /** + * The array of language tags, indexed by language code. + * + * @internal */ - static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } + static const LETag languageTags[]; private: @@ -138,56 +161,65 @@ private: static const LETag scriptTags[]; /** - * The array of language tags, indexed by language code. + * apply the typoflags. Only called by the c'tors. */ - static const LETag languageTags[]; + void applyTypoFlags(); +protected: /** - * The address of this static class variable serves as this class's ID - * for ICU "poor man's RTTI". + * A set of "default" features. The default characterProcessing method + * will apply all of these features to every glyph. + * + * @internal */ - static const char fgClassID; + FeatureMask fFeatureMask; -protected: /** - * An array of pointers to four byte feature tags. - * Each pointer points to a list of tags, terminated - * by a special empty tag. + * A set of mappings from feature tags to feature masks. These may + * be in the order in which the featues should be applied, but they + * don't need to be. * * @internal */ - const LETag **fFeatureTags; + const FeatureMap *fFeatureMap; /** - * A list of tags in the order in which the features in - * the font should be applied, as opposed to using the - * order of the lookups in the font. + * The length of the feature map. * * @internal */ - const LETag *fFeatureOrder; + le_int32 fFeatureMapCount; + + /** + * TRUE if the features in the + * feature map are in the order in which they + * must be applied. + * + * @internal + */ + le_bool fFeatureOrder; /** * The address of the GSUB table. * * @internal */ - const GlyphSubstitutionTableHeader *fGSUBTable; + LEReferenceTo fGSUBTable; /** * The address of the GDEF table. * * @internal */ - const GlyphDefinitionTableHeader *fGDEFTable; + LEReferenceTo fGDEFTable; /** * The address of the GPOS table. * * @internal */ - const GlyphPositioningTableHeader *fGPOSTable; - + LEReferenceTo fGPOSTable; + /** * An optional filter used to inhibit substitutions * preformed by the GSUB table. This is used for some @@ -204,6 +236,13 @@ protected: * @internal */ LETag fScriptTag; + + /** + * The four byte script tag for V2 fonts. + * + * @internal + */ + LETag fScriptTagV2; /** * The four byte language tag @@ -215,7 +254,7 @@ protected: /** * This method does the OpenType character processing. It assigns the OpenType feature * tags to the characters, and may generate output characters that differ from the input - * charcters dueto insertions, deletions, or reorderings. In such cases, it will also + * charcters due to insertions, deletions, or reorderings. In such cases, it will also * generate an output character index array reflecting these changes. * * Subclasses must override this method. @@ -225,7 +264,7 @@ protected: * @param offset - the index of the first character to process * @param count - the number of characters to process * @param max - the number of characters in the input context - * @param rightToLeft - true if the characters are in a right to left directional run + * @param rightToLeft - TRUE if the characters are in a right to left directional run * * Output parameters: * @param outChars - the output character array, if different from the input @@ -238,19 +277,7 @@ protected: * @internal */ virtual le_int32 characterProcessing(const LEUnicode /*chars*/[], le_int32 offset, le_int32 count, le_int32 max, le_bool /*rightToLeft*/, - LEUnicode *&/*outChars*/, le_int32 *&/*charIndices*/, const LETag **&/*featureTags*/, LEErrorCode &success) /*= 0;*/ - { - if (LE_FAILURE(success)) { - return 0; - } - - if (offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) { - success = LE_ILLEGAL_ARGUMENT_ERROR; - return 0; - } - - return count; - }; + LEUnicode *&/*outChars*/, LEGlyphStorage &glyphStorage, LEErrorCode &success); /** * This method does character to glyph mapping, and applies the GSUB table. The @@ -266,7 +293,7 @@ protected: * @param offset - the index of the first character to process * @param count - the number of characters to process * @param max - the number of characters in the input context - * @param rightToLeft - true if the characters are in a right to left directional run + * @param rightToLeft - TRUE if the characters are in a right to left directional run * @param featureTags - the feature tag array * * Output parameters: @@ -282,7 +309,9 @@ protected: * @internal */ virtual le_int32 glyphProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, - const LETag **featureTags, LEGlyphID *&glyphs, le_int32 *&charIndices, LEErrorCode &success); + LEGlyphStorage &glyphStorage, LEErrorCode &success); + + virtual le_int32 glyphSubstitution(le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success); /** * This method does any processing necessary to convert "fake" @@ -309,18 +338,7 @@ protected: * * @internal */ - virtual le_int32 glyphPostProcessing(LEGlyphID tempGlyphs[], le_int32 tempCharIndices[], le_int32 tempGlyphCount, - LEGlyphID *&glyphs, le_int32 *&charIndices, LEErrorCode &success) - { - if (LE_FAILURE(success)) { - return 0; - } - - glyphs = tempGlyphs; - charIndices = tempCharIndices; - - return tempGlyphCount; - }; + virtual le_int32 glyphPostProcessing(LEGlyphStorage &tempGlyphStorage, LEGlyphStorage &glyphStorage, LEErrorCode &success); /** * This method applies the characterProcessing, glyphProcessing and glyphPostProcessing @@ -331,7 +349,7 @@ protected: * @param offset - the index of the first character to process * @param count - the number of characters to process * @param max - the number of characters in the input context - * @param rightToLeft - true if the text is in a right to left directional run + * @param rightToLeft - TRUE if the text is in a right to left directional run * * Output parameters: * @param glyphs - the glyph index array @@ -344,7 +362,7 @@ protected: * * @internal */ - virtual le_int32 computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphID *&glyphs, le_int32 *&charIndices, LEErrorCode &success); + virtual le_int32 computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success); /** * This method uses the GPOS table, if there is one, to adjust the glyph positions. @@ -361,7 +379,7 @@ protected: * * @internal */ - virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphID glyphs[], le_int32 glyphCount, float positions[], LEErrorCode &success); + virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success); /** * This method frees the feature tag array so that the