summaryrefslogtreecommitdiffstats
path: root/icu.icuXXXX.malayalam.bysyllable.patch
blob: d0cd1b1642e5f66b4c0bd4a9f84e7c2935aeb7ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
diff -ruN icu.orig/source/layout/IndicReordering.h icu/source/layout/IndicReordering.h
--- icu.orig/source/layout/IndicReordering.h	2007-04-27 10:28:22.000000000 +0100
+++ icu/source/layout/IndicReordering.h	2007-04-27 10:39:22.000000000 +0100
@@ -142,6 +142,7 @@
     // do not instantiate
     IndicReordering();
 
+public:
     static le_int32 findSyllable(const IndicClassTable *classTable, const LEUnicode *chars, le_int32 prev, le_int32 charCount);
 
 };
diff -ruN icu.orig/source/layout/LayoutEngine.cpp icu/source/layout/LayoutEngine.cpp
--- icu.orig/source/layout/LayoutEngine.cpp	2007-04-27 10:28:22.000000000 +0100
+++ icu/source/layout/LayoutEngine.cpp	2007-04-27 10:39:22.000000000 +0100
@@ -14,6 +14,7 @@
 #include "CanonShaping.h"
 #include "HanLayoutEngine.h"
 #include "HangulLayoutEngine.h"
+#include "MalayalamLayoutEngine.h"
 #include "IndicLayoutEngine.h"
 #include "KhmerLayoutEngine.h"
 #include "ThaiLayoutEngine.h"
@@ -451,11 +452,13 @@
 
     if (gsubTable != NULL && gsubTable->coversScript(scriptTag = OpenTypeLayoutEngine::getScriptTag(scriptCode))) {
         switch (scriptCode) {
+        case mlymScriptCode:
+            result = new MalayalamOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable);
+	    break;
         case bengScriptCode:
         case devaScriptCode:
         case gujrScriptCode:
         case kndaScriptCode:
-        case mlymScriptCode:
         case oryaScriptCode:
         case guruScriptCode:
         case tamlScriptCode:
@@ -512,11 +515,13 @@
             result = new GXLayoutEngine(fontInstance, scriptCode, languageCode, morphTable);
         } else {
             switch (scriptCode) {
+            case mlymScriptCode:
+                result = new MalayalamOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags);
+	        break;
             case bengScriptCode:
             case devaScriptCode:
             case gujrScriptCode:
             case kndaScriptCode:
-            case mlymScriptCode:
             case oryaScriptCode:
             case guruScriptCode:
             case tamlScriptCode:
diff -ruN icu.orig/source/layout/LEGlyphStorage.h icu/source/layout/LEGlyphStorage.h
--- icu.orig/source/layout/LEGlyphStorage.h	2007-04-27 10:28:22.000000000 +0100
+++ icu/source/layout/LEGlyphStorage.h	2007-04-27 10:43:54.000000000 +0100
@@ -413,6 +413,8 @@
      */
     void adoptGlyphArray(LEGlyphStorage &from);
 
+    void appendGlyphStorage(LEGlyphStorage &from);
+
     /**
      * Delete the char indices array and replace it with the one
      * in <code>from</code>. Set the char indices array pointer
diff -ruN icu.orig/source/layout/Makefile.in icu/source/layout/Makefile.in
--- icu.orig/source/layout/Makefile.in	2007-04-27 10:28:22.000000000 +0100
+++ icu/source/layout/Makefile.in	2007-04-27 10:39:22.000000000 +0100
@@ -66,6 +66,7 @@
 ArabicLayoutEngine.o \
 GXLayoutEngine.o \
 HanLayoutEngine.o \
+MalayalamLayoutEngine.o \
 IndicLayoutEngine.o \
 LayoutEngine.o \
 ContextualGlyphSubstProc.o \
diff -ruN icu.orig/source/layout/MalayalamLayoutEngine.cpp icu/source/layout/MalayalamLayoutEngine.cpp
--- icu.orig/source/layout/MalayalamLayoutEngine.cpp	1970-01-01 01:00:00.000000000 +0100
+++ icu/source/layout/MalayalamLayoutEngine.cpp	2007-04-27 10:44:26.000000000 +0100
@@ -0,0 +1,126 @@
+
+/*
+ *
+ * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
+ *
+ */
+
+#include "LETypes.h"
+#include "LayoutEngine.h"
+#include "OpenTypeLayoutEngine.h"
+#include "MalayalamLayoutEngine.h"
+#include "ScriptAndLanguageTags.h"
+
+#include "GlyphSubstitutionTables.h"
+#include "GlyphDefinitionTables.h"
+#include "GlyphPositioningTables.h"
+
+#include "GDEFMarkFilter.h"
+#include "LEGlyphStorage.h"
+
+#include "IndicReordering.h"
+
+#include <stdio.h>
+
+U_NAMESPACE_BEGIN
+
+UOBJECT_DEFINE_RTTI_IMPLEMENTATION(MalayalamOpenTypeLayoutEngine)
+
+void LEGlyphStorage::appendGlyphStorage(LEGlyphStorage &from)
+{
+    if (fInsertionList) applyInsertions();
+    if (from.fInsertionList) from.applyInsertions();
+    if ((!fInsertionList) && (from.fInsertionList))
+    {
+        fInsertionList = from.fInsertionList;
+        from.fInsertionList = NULL;
+    }
+
+    if (!from.fGlyphCount)
+        return;
+
+    le_int32 newGlyphCount = fGlyphCount + from.fGlyphCount;
+
+    fGlyphs = (LEGlyphID*)LE_GROW_ARRAY(fGlyphs, newGlyphCount);
+    LE_ARRAY_COPY(fGlyphs+fGlyphCount, from.fGlyphs, from.fGlyphCount);
+
+    le_int32 nLargestIndex = 0;
+    if (fGlyphCount)
+    {
+        for (le_int32 i = 0; i < fGlyphCount; ++i)
+        {
+            if (fCharIndices[i] > nLargestIndex)
+                nLargestIndex = fCharIndices[i];
+        }
+        nLargestIndex+=1;
+    }
+    fCharIndices = (le_int32 *)LE_GROW_ARRAY(fCharIndices, newGlyphCount);
+    for (le_int32 i = 0; i < from.fGlyphCount; ++i)
+        fCharIndices[fGlyphCount+i] = from.fCharIndices[i] + nLargestIndex;
+
+    fAuxData = (le_uint32 *)LE_GROW_ARRAY(fAuxData, newGlyphCount);
+    LE_ARRAY_COPY(fAuxData+fGlyphCount, from.fAuxData, from.fGlyphCount);
+
+    fGlyphCount = newGlyphCount;
+}
+
+le_int32 MalayalamOpenTypeLayoutEngine::glyphPostProcessing(LEGlyphStorage &tempGlyphStorage, LEGlyphStorage &glyphStorage, LEErrorCode &success)
+{
+    if (LE_FAILURE(success)) {
+        return 0;
+    }
+
+    glyphStorage.appendGlyphStorage(tempGlyphStorage);
+
+    return glyphStorage.getGlyphCount();
+}
+
+
+le_int32 MalayalamOpenTypeLayoutEngine::computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success)
+{
+    if (LE_FAILURE(success)) {
+        return 0;
+    }
+
+    if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
+        success = LE_ILLEGAL_ARGUMENT_ERROR;
+        return 0;
+    }
+
+    le_int32 outGlyphCount=0;
+
+    const IndicClassTable *classTable = IndicClassTable::getScriptClassTable(fScriptCode);
+    le_int32 prev = 0;
+    while (prev < count)
+    { 
+        le_int32 outCharCount=0, fakeGlyphCount=0;
+        LEUnicode *outChars = NULL;
+        LEGlyphStorage fakeGlyphStorage;
+
+        le_int32 syllable = IndicReordering::findSyllable(classTable, chars+offset, prev, count);
+        outCharCount = characterProcessing(chars+prev, offset, syllable-prev, max, rightToLeft, outChars, fakeGlyphStorage, success);
+
+        if (LE_FAILURE(success)) {
+            return 0;
+        }
+
+        if (outChars != NULL) {
+            fakeGlyphCount = glyphProcessing(outChars, 0, outCharCount, outCharCount, rightToLeft, fakeGlyphStorage, success);
+            LE_DELETE_ARRAY(outChars); // FIXME: a subclass may have allocated this, in which case this delete might not work...
+        } else {
+            fakeGlyphCount = glyphProcessing(chars+prev, offset, syllable-prev, max, rightToLeft, fakeGlyphStorage, success);
+        }
+
+        if (LE_FAILURE(success)) {
+            return 0;
+        }
+
+        outGlyphCount = glyphPostProcessing(fakeGlyphStorage, glyphStorage, success);
+
+        prev = syllable;
+    }
+
+    return outGlyphCount;
+}
+
+U_NAMESPACE_END
diff -ruN icu.orig/source/layout/MalayalamLayoutEngine.h icu/source/layout/MalayalamLayoutEngine.h
--- icu.orig/source/layout/MalayalamLayoutEngine.h	1970-01-01 01:00:00.000000000 +0100
+++ icu/source/layout/MalayalamLayoutEngine.h	2007-04-27 10:39:52.000000000 +0100
@@ -0,0 +1,41 @@
+
+/*
+ *
+ * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
+ *
+ */
+
+#ifndef __MALAYALAMLAYOUTENGINE_H
+#define __MALAYALAMLAYOUTENGINE_H
+
+#include "IndicLayoutEngine.h"
+
+U_NAMESPACE_BEGIN
+
+class MalayalamOpenTypeLayoutEngine : public IndicOpenTypeLayoutEngine
+{
+public:
+    MalayalamOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
+                            le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable) :
+        IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable)
+
+    {}
+
+    MalayalamOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
+			      le_int32 typoFlags) :
+        IndicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags)
+
+    {}
+
+    virtual UClassID getDynamicClassID() const;
+    static UClassID getStaticClassID();
+
+protected:
+    virtual le_int32 glyphPostProcessing(LEGlyphStorage &tempGlyphStorage, LEGlyphStorage &glyphStorage, LEErrorCode &success);
+
+    virtual le_int32 computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success);
+};
+
+U_NAMESPACE_END
+#endif
+