4 * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
9 #include "LayoutEngine.h"
10 #include "ThaiLayoutEngine.h"
11 #include "ScriptAndLanguageTags.h"
12 #include "LEGlyphStorage.h"
14 #include "ThaiShaping.h"
18 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ThaiLayoutEngine
)
20 ThaiLayoutEngine::ThaiLayoutEngine(const LEFontInstance
*fontInstance
, le_int32 scriptCode
, le_int32 languageCode
)
21 : LayoutEngine(fontInstance
, scriptCode
, languageCode
)
25 // Figure out which presentation forms the font uses
26 if (fontInstance
->canDisplay(0x0E64)) {
27 // WorldType uses reserved space in Thai block
29 } else if (fontInstance
->canDisplay(0xF701)) {
30 // Microsoft corporate zone
33 if (!fontInstance
->canDisplay(fErrorChar
)) {
36 } else if (fontInstance
->canDisplay(0xF885)) {
37 // Apple corporate zone
40 // no presentation forms in the font
45 ThaiLayoutEngine::~ThaiLayoutEngine()
50 // Input: characters (0..max provided for context)
51 // Output: glyphs, char indices
52 // Returns: the glyph count
53 // NOTE: this assumes that ThaiShaping::compose will allocate the outChars array...
54 le_int32
ThaiLayoutEngine::computeGlyphs(const LEUnicode chars
[], le_int32 offset
, le_int32 count
, le_int32 max
, le_bool
/*rightToLeft*/, LEGlyphStorage
&glyphStorage
, LEErrorCode
&success
)
56 if (LE_FAILURE(success
)) {
60 if (chars
== NULL
|| offset
< 0 || count
< 0 || max
< 0 || offset
>= max
|| offset
+ count
> max
) {
61 success
= LE_ILLEGAL_ARGUMENT_ERROR
;
68 // This is enough room for the worst-case expansion
70 outChars
= LE_NEW_ARRAY(LEUnicode
, count
* 2);
72 if (outChars
== NULL
) {
73 success
= LE_MEMORY_ALLOCATION_ERROR
;
77 glyphStorage
.allocateGlyphArray(count
* 2, FALSE
, success
);
79 if (LE_FAILURE(success
)) {
80 LE_DELETE_ARRAY(outChars
);
81 success
= LE_MEMORY_ALLOCATION_ERROR
;
85 glyphCount
= ThaiShaping::compose(chars
, offset
, count
, fGlyphSet
, fErrorChar
, outChars
, glyphStorage
);
86 mapCharsToGlyphs(outChars
, 0, glyphCount
, FALSE
, FALSE
, glyphStorage
, success
);
88 LE_DELETE_ARRAY(outChars
);
90 glyphStorage
.adoptGlyphCount(glyphCount
);