sl@0
|
1 |
|
sl@0
|
2 |
/*
|
sl@0
|
3 |
*
|
sl@0
|
4 |
* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
|
sl@0
|
5 |
*
|
sl@0
|
6 |
* This file is a modification of the ICU file IndicLayoutEngine.cpp
|
sl@0
|
7 |
* by Jens Herden and Javier Sola for Khmer language
|
sl@0
|
8 |
*
|
sl@0
|
9 |
*/
|
sl@0
|
10 |
|
sl@0
|
11 |
|
sl@0
|
12 |
#include "OpenTypeLayoutEngine.h"
|
sl@0
|
13 |
#include "KhmerLayoutEngine.h"
|
sl@0
|
14 |
#include "LEGlyphStorage.h"
|
sl@0
|
15 |
#include "KhmerReordering.h"
|
sl@0
|
16 |
|
sl@0
|
17 |
U_NAMESPACE_BEGIN
|
sl@0
|
18 |
|
sl@0
|
19 |
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(KhmerOpenTypeLayoutEngine)
|
sl@0
|
20 |
|
sl@0
|
21 |
KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
|
sl@0
|
22 |
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable)
|
sl@0
|
23 |
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable)
|
sl@0
|
24 |
{
|
sl@0
|
25 |
fFeatureOrder = KhmerReordering::getFeatureOrder();
|
sl@0
|
26 |
}
|
sl@0
|
27 |
|
sl@0
|
28 |
KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
|
sl@0
|
29 |
le_int32 typoFlags)
|
sl@0
|
30 |
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags)
|
sl@0
|
31 |
{
|
sl@0
|
32 |
fFeatureOrder = KhmerReordering::getFeatureOrder();
|
sl@0
|
33 |
}
|
sl@0
|
34 |
|
sl@0
|
35 |
KhmerOpenTypeLayoutEngine::~KhmerOpenTypeLayoutEngine()
|
sl@0
|
36 |
{
|
sl@0
|
37 |
// nothing to do
|
sl@0
|
38 |
}
|
sl@0
|
39 |
|
sl@0
|
40 |
// Input: characters
|
sl@0
|
41 |
// Output: characters, char indices, tags
|
sl@0
|
42 |
// Returns: output character count
|
sl@0
|
43 |
le_int32 KhmerOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
|
sl@0
|
44 |
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success)
|
sl@0
|
45 |
{
|
sl@0
|
46 |
if (LE_FAILURE(success)) {
|
sl@0
|
47 |
return 0;
|
sl@0
|
48 |
}
|
sl@0
|
49 |
|
sl@0
|
50 |
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
|
sl@0
|
51 |
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
sl@0
|
52 |
return 0;
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
le_int32 worstCase = count * 3; // worst case is 3 for Khmer TODO check if 2 is enough
|
sl@0
|
56 |
|
sl@0
|
57 |
outChars = LE_NEW_ARRAY(LEUnicode, worstCase);
|
sl@0
|
58 |
|
sl@0
|
59 |
if (outChars == NULL) {
|
sl@0
|
60 |
success = LE_MEMORY_ALLOCATION_ERROR;
|
sl@0
|
61 |
return 0;
|
sl@0
|
62 |
}
|
sl@0
|
63 |
|
sl@0
|
64 |
glyphStorage.allocateGlyphArray(worstCase, rightToLeft, success);
|
sl@0
|
65 |
glyphStorage.allocateAuxData(success);
|
sl@0
|
66 |
|
sl@0
|
67 |
if (LE_FAILURE(success)) {
|
sl@0
|
68 |
LE_DELETE_ARRAY(outChars);
|
sl@0
|
69 |
return 0;
|
sl@0
|
70 |
}
|
sl@0
|
71 |
|
sl@0
|
72 |
// NOTE: assumes this allocates featureTags...
|
sl@0
|
73 |
// (probably better than doing the worst case stuff here...)
|
sl@0
|
74 |
le_int32 outCharCount = KhmerReordering::reorder(&chars[offset], count, fScriptCode, outChars, glyphStorage);
|
sl@0
|
75 |
|
sl@0
|
76 |
glyphStorage.adoptGlyphCount(outCharCount);
|
sl@0
|
77 |
return outCharCount;
|
sl@0
|
78 |
}
|
sl@0
|
79 |
|
sl@0
|
80 |
U_NAMESPACE_END
|