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 |
*/
|
sl@0
|
7 |
|
sl@0
|
8 |
#include "LETypes.h"
|
sl@0
|
9 |
#include "LayoutEngine.h"
|
sl@0
|
10 |
#include "OpenTypeLayoutEngine.h"
|
sl@0
|
11 |
#include "IndicLayoutEngine.h"
|
sl@0
|
12 |
#include "ScriptAndLanguageTags.h"
|
sl@0
|
13 |
|
sl@0
|
14 |
#include "GlyphSubstitutionTables.h"
|
sl@0
|
15 |
#include "GlyphDefinitionTables.h"
|
sl@0
|
16 |
#include "GlyphPositioningTables.h"
|
sl@0
|
17 |
|
sl@0
|
18 |
#include "GDEFMarkFilter.h"
|
sl@0
|
19 |
#include "LEGlyphStorage.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
#include "IndicReordering.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
U_NAMESPACE_BEGIN
|
sl@0
|
24 |
|
sl@0
|
25 |
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(IndicOpenTypeLayoutEngine)
|
sl@0
|
26 |
|
sl@0
|
27 |
IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
|
sl@0
|
28 |
le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable)
|
sl@0
|
29 |
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable), fMPreFixups(NULL)
|
sl@0
|
30 |
{
|
sl@0
|
31 |
fFeatureOrder = IndicReordering::getFeatureOrder();
|
sl@0
|
32 |
}
|
sl@0
|
33 |
|
sl@0
|
34 |
IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags)
|
sl@0
|
35 |
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags), fMPreFixups(NULL)
|
sl@0
|
36 |
{
|
sl@0
|
37 |
fFeatureOrder = IndicReordering::getFeatureOrder();
|
sl@0
|
38 |
}
|
sl@0
|
39 |
|
sl@0
|
40 |
IndicOpenTypeLayoutEngine::~IndicOpenTypeLayoutEngine()
|
sl@0
|
41 |
{
|
sl@0
|
42 |
// nothing to do
|
sl@0
|
43 |
}
|
sl@0
|
44 |
|
sl@0
|
45 |
// Input: characters, tags
|
sl@0
|
46 |
// Output: glyphs, char indices
|
sl@0
|
47 |
le_int32 IndicOpenTypeLayoutEngine::glyphProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
|
sl@0
|
48 |
LEGlyphStorage &glyphStorage, LEErrorCode &success)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
if (LE_FAILURE(success)) {
|
sl@0
|
51 |
return 0;
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
|
sl@0
|
55 |
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
sl@0
|
56 |
return 0;
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
le_int32 retCount = OpenTypeLayoutEngine::glyphProcessing(chars, offset, count, max, rightToLeft, glyphStorage, success);
|
sl@0
|
60 |
|
sl@0
|
61 |
if (LE_FAILURE(success)) {
|
sl@0
|
62 |
return 0;
|
sl@0
|
63 |
}
|
sl@0
|
64 |
|
sl@0
|
65 |
IndicReordering::adjustMPres(fMPreFixups, glyphStorage, success);
|
sl@0
|
66 |
|
sl@0
|
67 |
return retCount;
|
sl@0
|
68 |
}
|
sl@0
|
69 |
|
sl@0
|
70 |
// Input: characters
|
sl@0
|
71 |
// Output: characters, char indices, tags
|
sl@0
|
72 |
// Returns: output character count
|
sl@0
|
73 |
le_int32 IndicOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
|
sl@0
|
74 |
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success)
|
sl@0
|
75 |
{
|
sl@0
|
76 |
if (LE_FAILURE(success)) {
|
sl@0
|
77 |
return 0;
|
sl@0
|
78 |
}
|
sl@0
|
79 |
|
sl@0
|
80 |
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
|
sl@0
|
81 |
success = LE_ILLEGAL_ARGUMENT_ERROR;
|
sl@0
|
82 |
return 0;
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|
sl@0
|
85 |
le_int32 worstCase = count * IndicReordering::getWorstCaseExpansion(fScriptCode);
|
sl@0
|
86 |
|
sl@0
|
87 |
outChars = LE_NEW_ARRAY(LEUnicode, worstCase);
|
sl@0
|
88 |
|
sl@0
|
89 |
if (outChars == NULL) {
|
sl@0
|
90 |
success = LE_MEMORY_ALLOCATION_ERROR;
|
sl@0
|
91 |
return 0;
|
sl@0
|
92 |
}
|
sl@0
|
93 |
|
sl@0
|
94 |
glyphStorage.allocateGlyphArray(worstCase, rightToLeft, success);
|
sl@0
|
95 |
glyphStorage.allocateAuxData(success);
|
sl@0
|
96 |
|
sl@0
|
97 |
if (LE_FAILURE(success)) {
|
sl@0
|
98 |
LE_DELETE_ARRAY(outChars);
|
sl@0
|
99 |
outChars = NULL;
|
sl@0
|
100 |
return 0;
|
sl@0
|
101 |
}
|
sl@0
|
102 |
|
sl@0
|
103 |
// NOTE: assumes this allocates featureTags...
|
sl@0
|
104 |
// (probably better than doing the worst case stuff here...)
|
sl@0
|
105 |
le_int32 outCharCount = IndicReordering::reorder(&chars[offset], count,
|
sl@0
|
106 |
fScriptCode, outChars, glyphStorage, &fMPreFixups, success);
|
sl@0
|
107 |
|
sl@0
|
108 |
if (LE_FAILURE(success)) {
|
sl@0
|
109 |
LE_DELETE_ARRAY(outChars);
|
sl@0
|
110 |
outChars = NULL;
|
sl@0
|
111 |
return 0;
|
sl@0
|
112 |
}
|
sl@0
|
113 |
|
sl@0
|
114 |
glyphStorage.adoptGlyphCount(outCharCount);
|
sl@0
|
115 |
return outCharCount;
|
sl@0
|
116 |
}
|
sl@0
|
117 |
|
sl@0
|
118 |
U_NAMESPACE_END
|