sl@0: sl@0: /* sl@0: * sl@0: * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved sl@0: * sl@0: * This file is a modification of the ICU file IndicLayoutEngine.cpp sl@0: * by Jens Herden and Javier Sola for Khmer language sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include "OpenTypeLayoutEngine.h" sl@0: #include "KhmerLayoutEngine.h" sl@0: #include "LEGlyphStorage.h" sl@0: #include "KhmerReordering.h" sl@0: sl@0: U_NAMESPACE_BEGIN sl@0: sl@0: UOBJECT_DEFINE_RTTI_IMPLEMENTATION(KhmerOpenTypeLayoutEngine) sl@0: sl@0: KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, sl@0: le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable) sl@0: : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable) sl@0: { sl@0: fFeatureOrder = KhmerReordering::getFeatureOrder(); sl@0: } sl@0: sl@0: KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, sl@0: le_int32 typoFlags) sl@0: : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags) sl@0: { sl@0: fFeatureOrder = KhmerReordering::getFeatureOrder(); sl@0: } sl@0: sl@0: KhmerOpenTypeLayoutEngine::~KhmerOpenTypeLayoutEngine() sl@0: { sl@0: // nothing to do sl@0: } sl@0: sl@0: // Input: characters sl@0: // Output: characters, char indices, tags sl@0: // Returns: output character count sl@0: le_int32 KhmerOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, sl@0: LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success) sl@0: { sl@0: if (LE_FAILURE(success)) { sl@0: return 0; sl@0: } sl@0: sl@0: if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) { sl@0: success = LE_ILLEGAL_ARGUMENT_ERROR; sl@0: return 0; sl@0: } sl@0: sl@0: le_int32 worstCase = count * 3; // worst case is 3 for Khmer TODO check if 2 is enough sl@0: sl@0: outChars = LE_NEW_ARRAY(LEUnicode, worstCase); sl@0: sl@0: if (outChars == NULL) { sl@0: success = LE_MEMORY_ALLOCATION_ERROR; sl@0: return 0; sl@0: } sl@0: sl@0: glyphStorage.allocateGlyphArray(worstCase, rightToLeft, success); sl@0: glyphStorage.allocateAuxData(success); sl@0: sl@0: if (LE_FAILURE(success)) { sl@0: LE_DELETE_ARRAY(outChars); sl@0: return 0; sl@0: } sl@0: sl@0: // NOTE: assumes this allocates featureTags... sl@0: // (probably better than doing the worst case stuff here...) sl@0: le_int32 outCharCount = KhmerReordering::reorder(&chars[offset], count, fScriptCode, outChars, glyphStorage); sl@0: sl@0: glyphStorage.adoptGlyphCount(outCharCount); sl@0: return outCharCount; sl@0: } sl@0: sl@0: U_NAMESPACE_END