3 * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
5 * This file is a modification of the ICU file IndicLayoutEngine.cpp
6 * by Jens Herden and Javier Sola for Khmer language
11 #include "OpenTypeLayoutEngine.h"
12 #include "KhmerLayoutEngine.h"
13 #include "LEGlyphStorage.h"
14 #include "KhmerReordering.h"
18 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(KhmerOpenTypeLayoutEngine
)
20 KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance
*fontInstance
, le_int32 scriptCode
, le_int32 languageCode
,
21 le_int32 typoFlags
, const LEReferenceTo
<GlyphSubstitutionTableHeader
> &gsubTable
, LEErrorCode
&success
)
22 : OpenTypeLayoutEngine(fontInstance
, scriptCode
, languageCode
, typoFlags
, gsubTable
, success
)
24 fFeatureMap
= KhmerReordering::getFeatureMap(fFeatureMapCount
);
28 KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance
*fontInstance
, le_int32 scriptCode
, le_int32 languageCode
,
29 le_int32 typoFlags
, LEErrorCode
&success
)
30 : OpenTypeLayoutEngine(fontInstance
, scriptCode
, languageCode
, typoFlags
, success
)
32 fFeatureMap
= KhmerReordering::getFeatureMap(fFeatureMapCount
);
36 KhmerOpenTypeLayoutEngine::~KhmerOpenTypeLayoutEngine()
42 // Output: characters, char indices, tags
43 // Returns: output character count
44 le_int32
KhmerOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars
[], le_int32 offset
, le_int32 count
, le_int32 max
, le_bool rightToLeft
,
45 LEUnicode
*&outChars
, LEGlyphStorage
&glyphStorage
, LEErrorCode
&success
)
47 if (LE_FAILURE(success
)) {
51 if (chars
== NULL
|| offset
< 0 || count
< 0 || max
< 0 || offset
>= max
|| offset
+ count
> max
) {
52 success
= LE_ILLEGAL_ARGUMENT_ERROR
;
56 le_int32 worstCase
= count
* 3; // worst case is 3 for Khmer TODO check if 2 is enough
58 outChars
= LE_NEW_ARRAY(LEUnicode
, worstCase
);
60 if (outChars
== NULL
) {
61 success
= LE_MEMORY_ALLOCATION_ERROR
;
65 glyphStorage
.allocateGlyphArray(worstCase
, rightToLeft
, success
);
66 glyphStorage
.allocateAuxData(success
);
68 if (LE_FAILURE(success
)) {
69 LE_DELETE_ARRAY(outChars
);
73 // NOTE: assumes this allocates featureTags...
74 // (probably better than doing the worst case stuff here...)
75 le_int32 outCharCount
= KhmerReordering::reorder(&chars
[offset
], count
, fScriptCode
, outChars
, glyphStorage
);
77 glyphStorage
.adoptGlyphCount(outCharCount
);