3 * @(#)IndicLayoutEngine.cpp 1.3 00/03/15
5 * (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved
10 #include "LayoutEngine.h"
11 #include "OpenTypeLayoutEngine.h"
12 #include "IndicLayoutEngine.h"
13 #include "ScriptAndLanguageTags.h"
15 #include "GlyphSubstitutionTables.h"
16 #include "GlyphDefinitionTables.h"
17 #include "GlyphPositioningTables.h"
19 #include "GDEFMarkFilter.h"
21 #include "IndicReordering.h"
25 const char IndicOpenTypeLayoutEngine::fgClassID
=0;
27 IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance
*fontInstance
, le_int32 scriptCode
, le_int32 languageCode
,
28 const GlyphSubstitutionTableHeader
*gsubTable
)
29 : OpenTypeLayoutEngine(fontInstance
, scriptCode
, languageCode
, gsubTable
), fMPreFixups(NULL
)
31 fFeatureOrder
= IndicReordering::getFeatureOrder();
34 IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance
*fontInstance
, le_int32 scriptCode
, le_int32 languageCode
)
35 : OpenTypeLayoutEngine(fontInstance
, scriptCode
, languageCode
), fMPreFixups(NULL
)
37 fFeatureOrder
= IndicReordering::getFeatureOrder();
40 IndicOpenTypeLayoutEngine::~IndicOpenTypeLayoutEngine()
45 // Input: characters, tags
46 // Output: glyphs, char indices
47 le_int32
IndicOpenTypeLayoutEngine::glyphProcessing(const LEUnicode chars
[], le_int32 offset
, le_int32 count
, le_int32 max
, le_bool rightToLeft
, const LETag
**featureTags
,
48 LEGlyphID
*&glyphs
, le_int32
*&charIndices
, LEErrorCode
&success
)
50 if (LE_FAILURE(success
)) {
54 if (chars
== NULL
|| offset
< 0 || count
< 0 || max
< 0 || offset
>= max
|| offset
+ count
> max
) {
55 success
= LE_ILLEGAL_ARGUMENT_ERROR
;
59 le_int32 retCount
= OpenTypeLayoutEngine::glyphProcessing(chars
, offset
, count
, max
, rightToLeft
, featureTags
, glyphs
, charIndices
, success
);
61 if (LE_FAILURE(success
)) {
65 IndicReordering::adjustMPres(fMPreFixups
, glyphs
, charIndices
);
71 // Output: characters, char indices, tags
72 // Returns: output character count
73 le_int32
IndicOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars
[], le_int32 offset
, le_int32 count
, le_int32 max
, le_bool
/*rightToLeft*/,
74 LEUnicode
*&outChars
, le_int32
*&charIndices
, const LETag
**&featureTags
, LEErrorCode
&success
)
76 if (LE_FAILURE(success
)) {
80 if (chars
== NULL
|| offset
< 0 || count
< 0 || max
< 0 || offset
>= max
|| offset
+ count
> max
) {
81 success
= LE_ILLEGAL_ARGUMENT_ERROR
;
85 le_int32 worstCase
= count
* IndicReordering::getWorstCaseExpansion(fScriptCode
);
87 outChars
= LE_NEW_ARRAY(LEUnicode
, worstCase
);
89 if (outChars
== NULL
) {
90 success
= LE_MEMORY_ALLOCATION_ERROR
;
94 charIndices
= LE_NEW_ARRAY(le_int32
, worstCase
);
95 if (charIndices
== NULL
) {
96 LE_DELETE_ARRAY(outChars
);
97 success
= LE_MEMORY_ALLOCATION_ERROR
;
101 featureTags
= LE_NEW_ARRAY(const LETag
*, worstCase
);
103 if (featureTags
== NULL
) {
104 LE_DELETE_ARRAY(charIndices
);
105 LE_DELETE_ARRAY(outChars
);
106 success
= LE_MEMORY_ALLOCATION_ERROR
;
110 // NOTE: assumes this allocates featureTags...
111 // (probably better than doing the worst case stuff here...)
112 return IndicReordering::reorder(&chars
[offset
], count
, fScriptCode
, outChars
, charIndices
, featureTags
, &fMPreFixups
);