2
|
1 |
/*
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3 |
*
|
|
4 |
* This code is free software; you can redistribute it and/or modify it
|
|
5 |
* under the terms of the GNU General Public License version 2 only, as
|
5506
|
6 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
7 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
8 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
9 |
*
|
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
14 |
* accompanied this code).
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License version
|
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
19 |
*
|
5506
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
21 |
* or visit www.oracle.com if you need additional information or have any
|
|
22 |
* questions.
|
2
|
23 |
*
|
|
24 |
*/
|
|
25 |
|
3935
|
26 |
|
2
|
27 |
/*
|
7486
|
28 |
* (C) Copyright IBM Corp. 1998-2008 - All Rights Reserved
|
2
|
29 |
*
|
|
30 |
* This file is a modification of the ICU file IndicLayoutEngine.cpp
|
|
31 |
* by Jens Herden and Javier Sola for Khmer language
|
|
32 |
*
|
|
33 |
*/
|
|
34 |
|
|
35 |
|
|
36 |
#include "OpenTypeLayoutEngine.h"
|
|
37 |
#include "KhmerLayoutEngine.h"
|
|
38 |
#include "LEGlyphStorage.h"
|
|
39 |
#include "KhmerReordering.h"
|
|
40 |
|
3935
|
41 |
U_NAMESPACE_BEGIN
|
|
42 |
|
|
43 |
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(KhmerOpenTypeLayoutEngine)
|
|
44 |
|
|
45 |
KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
|
16891
|
46 |
le_int32 typoFlags, const LEReferenceTo<GlyphSubstitutionTableHeader> &gsubTable, LEErrorCode &success)
|
7486
|
47 |
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable, success)
|
2
|
48 |
{
|
|
49 |
fFeatureMap = KhmerReordering::getFeatureMap(fFeatureMapCount);
|
|
50 |
fFeatureOrder = TRUE;
|
|
51 |
}
|
|
52 |
|
3935
|
53 |
KhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
|
7486
|
54 |
le_int32 typoFlags, LEErrorCode &success)
|
|
55 |
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success)
|
2
|
56 |
{
|
|
57 |
fFeatureMap = KhmerReordering::getFeatureMap(fFeatureMapCount);
|
|
58 |
fFeatureOrder = TRUE;
|
|
59 |
}
|
|
60 |
|
|
61 |
KhmerOpenTypeLayoutEngine::~KhmerOpenTypeLayoutEngine()
|
|
62 |
{
|
|
63 |
// nothing to do
|
|
64 |
}
|
|
65 |
|
|
66 |
// Input: characters
|
|
67 |
// Output: characters, char indices, tags
|
|
68 |
// Returns: output character count
|
3935
|
69 |
le_int32 KhmerOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
|
|
70 |
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success)
|
2
|
71 |
{
|
|
72 |
if (LE_FAILURE(success)) {
|
|
73 |
return 0;
|
|
74 |
}
|
|
75 |
|
3935
|
76 |
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
|
2
|
77 |
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
|
78 |
return 0;
|
|
79 |
}
|
|
80 |
|
|
81 |
le_int32 worstCase = count * 3; // worst case is 3 for Khmer TODO check if 2 is enough
|
|
82 |
|
|
83 |
outChars = LE_NEW_ARRAY(LEUnicode, worstCase);
|
|
84 |
|
|
85 |
if (outChars == NULL) {
|
|
86 |
success = LE_MEMORY_ALLOCATION_ERROR;
|
|
87 |
return 0;
|
|
88 |
}
|
|
89 |
|
|
90 |
glyphStorage.allocateGlyphArray(worstCase, rightToLeft, success);
|
|
91 |
glyphStorage.allocateAuxData(success);
|
|
92 |
|
|
93 |
if (LE_FAILURE(success)) {
|
|
94 |
LE_DELETE_ARRAY(outChars);
|
|
95 |
return 0;
|
|
96 |
}
|
|
97 |
|
|
98 |
// NOTE: assumes this allocates featureTags...
|
|
99 |
// (probably better than doing the worst case stuff here...)
|
3935
|
100 |
le_int32 outCharCount = KhmerReordering::reorder(&chars[offset], count, fScriptCode, outChars, glyphStorage);
|
2
|
101 |
|
|
102 |
glyphStorage.adoptGlyphCount(outCharCount);
|
|
103 |
return outCharCount;
|
|
104 |
}
|
3935
|
105 |
|
|
106 |
U_NAMESPACE_END
|