os/textandloc/fontservices/textshaperplugin/IcuSource/layout/KhmerLayoutEngine.cpp
Update contrib.
4 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
6 * This file is a modification of the ICU file IndicLayoutEngine.cpp
7 * by Jens Herden and Javier Sola for Khmer language
12 #include "OpenTypeLayoutEngine.h"
13 #include "KhmerLayoutEngine.h"
14 #include "LEGlyphStorage.h"
15 #include "KhmerReordering.h"
19 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(KhmerOpenTypeLayoutEngine)
21 KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
22 le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable)
23 : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable)
25 fFeatureOrder = KhmerReordering::getFeatureOrder();
28 KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
30 : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags)
32 fFeatureOrder = KhmerReordering::getFeatureOrder();
35 KhmerOpenTypeLayoutEngine::~KhmerOpenTypeLayoutEngine()
41 // Output: characters, char indices, tags
42 // Returns: output character count
43 le_int32 KhmerOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
44 LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success)
46 if (LE_FAILURE(success)) {
50 if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
51 success = LE_ILLEGAL_ARGUMENT_ERROR;
55 le_int32 worstCase = count * 3; // worst case is 3 for Khmer TODO check if 2 is enough
57 outChars = LE_NEW_ARRAY(LEUnicode, worstCase);
59 if (outChars == NULL) {
60 success = LE_MEMORY_ALLOCATION_ERROR;
64 glyphStorage.allocateGlyphArray(worstCase, rightToLeft, success);
65 glyphStorage.allocateAuxData(success);
67 if (LE_FAILURE(success)) {
68 LE_DELETE_ARRAY(outChars);
72 // NOTE: assumes this allocates featureTags...
73 // (probably better than doing the worst case stuff here...)
74 le_int32 outCharCount = KhmerReordering::reorder(&chars[offset], count, fScriptCode, outChars, glyphStorage);
76 glyphStorage.adoptGlyphCount(outCharCount);