X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b75a7d8f3b4adbae880cab104ce2c6a50eee4db2..ef6cf650f4a75c3f97de06b51fa104f2069b9ea2:/icuSources/layout/IndicLayoutEngine.cpp diff --git a/icuSources/layout/IndicLayoutEngine.cpp b/icuSources/layout/IndicLayoutEngine.cpp index 92f53541..cc9815cf 100644 --- a/icuSources/layout/IndicLayoutEngine.cpp +++ b/icuSources/layout/IndicLayoutEngine.cpp @@ -1,8 +1,7 @@ /* - * @(#)IndicLayoutEngine.cpp 1.3 00/03/15 * - * (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved + * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved * */ @@ -17,24 +16,34 @@ #include "GlyphPositioningTables.h" #include "GDEFMarkFilter.h" +#include "LEGlyphStorage.h" #include "IndicReordering.h" U_NAMESPACE_BEGIN -const char IndicOpenTypeLayoutEngine::fgClassID=0; +UOBJECT_DEFINE_RTTI_IMPLEMENTATION(IndicOpenTypeLayoutEngine) IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, - const GlyphSubstitutionTableHeader *gsubTable) - : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, gsubTable), fMPreFixups(NULL) + le_int32 typoFlags, le_bool version2, const LEReferenceTo &gsubTable, LEErrorCode &success) + : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable, success), fMPreFixups(NULL) { - fFeatureOrder = IndicReordering::getFeatureOrder(); + if ( version2 ) { + fFeatureMap = IndicReordering::getv2FeatureMap(fFeatureMapCount); + } else { + fFeatureMap = IndicReordering::getFeatureMap(fFeatureMapCount); + } + fFeatureOrder = TRUE; + fVersion2 = version2; + fFilterZeroWidth = IndicReordering::getFilterZeroWidth(fScriptCode); } -IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode) - : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode), fMPreFixups(NULL) +IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags, LEErrorCode &success) + : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success), fMPreFixups(NULL) { - fFeatureOrder = IndicReordering::getFeatureOrder(); + fFeatureMap = IndicReordering::getFeatureMap(fFeatureMapCount); + fFeatureOrder = TRUE; + fVersion2 = FALSE; } IndicOpenTypeLayoutEngine::~IndicOpenTypeLayoutEngine() @@ -44,8 +53,8 @@ IndicOpenTypeLayoutEngine::~IndicOpenTypeLayoutEngine() // Input: characters, tags // Output: glyphs, char indices -le_int32 IndicOpenTypeLayoutEngine::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) +le_int32 IndicOpenTypeLayoutEngine::glyphProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, + LEGlyphStorage &glyphStorage, LEErrorCode &success) { if (LE_FAILURE(success)) { return 0; @@ -56,22 +65,27 @@ le_int32 IndicOpenTypeLayoutEngine::glyphProcessing(const LEUnicode chars[], le_ return 0; } - le_int32 retCount = OpenTypeLayoutEngine::glyphProcessing(chars, offset, count, max, rightToLeft, featureTags, glyphs, charIndices, success); + le_int32 retCount = OpenTypeLayoutEngine::glyphProcessing(chars, offset, count, max, rightToLeft, glyphStorage, success); if (LE_FAILURE(success)) { return 0; } - IndicReordering::adjustMPres(fMPreFixups, glyphs, charIndices); - + if (fVersion2) { + IndicReordering::finalReordering(glyphStorage,retCount); + IndicReordering::applyPresentationForms(glyphStorage,retCount); + OpenTypeLayoutEngine::glyphSubstitution(count,max, rightToLeft, glyphStorage, success); + } else { + IndicReordering::adjustMPres(fMPreFixups, glyphStorage, success); + } return retCount; } // Input: characters // Output: characters, char indices, tags // Returns: output character count -le_int32 IndicOpenTypeLayoutEngine::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) +le_int32 IndicOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, + LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success) { if (LE_FAILURE(success)) { return 0; @@ -91,25 +105,31 @@ le_int32 IndicOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], return 0; } - charIndices = LE_NEW_ARRAY(le_int32, worstCase); - if (charIndices == NULL) { + glyphStorage.allocateGlyphArray(worstCase, rightToLeft, success); + glyphStorage.allocateAuxData(success); + + if (LE_FAILURE(success)) { LE_DELETE_ARRAY(outChars); - success = LE_MEMORY_ALLOCATION_ERROR; return 0; } - featureTags = LE_NEW_ARRAY(const LETag *, worstCase); + // NOTE: assumes this allocates featureTags... + // (probably better than doing the worst case stuff here...) - if (featureTags == NULL) { - LE_DELETE_ARRAY(charIndices); + le_int32 outCharCount; + if (fVersion2) { + outCharCount = IndicReordering::v2process(&chars[offset], count, fScriptCode, outChars, glyphStorage); + } else { + outCharCount = IndicReordering::reorder(&chars[offset], count, fScriptCode, outChars, glyphStorage, &fMPreFixups, success); + } + + if (LE_FAILURE(success)) { LE_DELETE_ARRAY(outChars); - success = LE_MEMORY_ALLOCATION_ERROR; return 0; } - // NOTE: assumes this allocates featureTags... - // (probably better than doing the worst case stuff here...) - return IndicReordering::reorder(&chars[offset], count, fScriptCode, outChars, charIndices, featureTags, &fMPreFixups); + glyphStorage.adoptGlyphCount(outCharCount); + return outCharCount; } U_NAMESPACE_END