3 * (C) Copyright IBM Corp. and others 1998-2013 - All Rights Reserved
8 #include "MorphTables.h"
9 #include "StateTables.h"
10 #include "MorphStateTables.h"
11 #include "SubtableProcessor2.h"
12 #include "StateTableProcessor2.h"
13 #include "ContextualGlyphInsertionProc2.h"
14 #include "LEGlyphStorage.h"
19 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ContextualGlyphInsertionProcessor2
)
21 ContextualGlyphInsertionProcessor2::ContextualGlyphInsertionProcessor2(const MorphSubtableHeader2
*morphSubtableHeader
)
22 : StateTableProcessor2(morphSubtableHeader
)
24 contextualGlyphHeader
= (const ContextualGlyphInsertionHeader2
*) morphSubtableHeader
;
25 le_uint32 insertionTableOffset
= SWAPL(contextualGlyphHeader
->insertionTableOffset
);
26 insertionTable
= ((le_uint16
*) ((char *)&stateTableHeader
->stHeader
+ insertionTableOffset
));
27 entryTable
= (const ContextualGlyphInsertionStateEntry2
*) ((char *) &stateTableHeader
->stHeader
+ entryTableOffset
);
30 ContextualGlyphInsertionProcessor2::~ContextualGlyphInsertionProcessor2()
34 void ContextualGlyphInsertionProcessor2::beginStateTable()
39 le_uint16
ContextualGlyphInsertionProcessor2::processStateEntry(LEGlyphStorage
&glyphStorage
, le_int32
&currGlyph
, EntryTableIndex2 index
)
41 const ContextualGlyphInsertionStateEntry2
*entry
= &entryTable
[index
];
42 le_uint16 newState
= SWAPW(entry
->newStateIndex
);
43 le_uint16 flags
= SWAPW(entry
->flags
);
44 le_int16 currIndex
= SWAPW(entry
->currentInsertionListIndex
);
45 le_int16 markIndex
= SWAPW(entry
->markedInsertionListIndex
);
49 le_int16 count
= (flags
& cgiMarkedInsertCountMask
) >> 5;
50 if (!(flags
& cgiMarkedIsKashidaLike
)) {
51 // extra glyph(s) will be added directly before/after the specified marked glyph
52 if (!(flags
& cgiMarkInsertBefore
)) {
53 LEGlyphID
*insertGlyphs
= glyphStorage
.insertGlyphs(markGlyph
, count
+ 1);
54 for (i
= 0; i
< count
; i
++, markIndex
++) {
55 insertGlyphs
[i
] = insertionTable
[markIndex
];
57 insertGlyphs
[i
] = glyphStorage
[markGlyph
];
58 glyphStorage
.applyInsertions();
60 LEGlyphID
*insertGlyphs
= glyphStorage
.insertGlyphs(markGlyph
, count
+ 1);
61 insertGlyphs
[0] = glyphStorage
[markGlyph
];
62 for (i
= 1; i
< count
+ 1; i
++, markIndex
++) {
63 insertGlyphs
[i
] = insertionTable
[markIndex
];
65 glyphStorage
.applyInsertions();
68 // inserted as a split-vowel-like insertion
69 // extra glyph(s) will be inserted some distance away from the marked glyph
70 if (!(flags
& cgiMarkInsertBefore
)) {
71 LEGlyphID
*insertGlyphs
= glyphStorage
.insertGlyphs(markGlyph
, count
+ 1);
72 for (i
= 0; i
< count
; i
++, markIndex
++) {
73 insertGlyphs
[i
] = insertionTable
[markIndex
];
75 insertGlyphs
[i
] = glyphStorage
[markGlyph
];
76 glyphStorage
.applyInsertions();
78 LEGlyphID
*insertGlyphs
= glyphStorage
.insertGlyphs(markGlyph
, count
+ 1);
79 insertGlyphs
[0] = glyphStorage
[markGlyph
];
80 for (i
= 1; i
< count
+ 1; i
++, markIndex
++) {
81 insertGlyphs
[i
] = insertionTable
[markIndex
];
83 glyphStorage
.applyInsertions();
89 le_int16 count
= flags
& cgiCurrentInsertCountMask
;
90 if (!(flags
& cgiCurrentIsKashidaLike
)) {
91 // extra glyph(s) will be added directly before/after the specified current glyph
92 if (!(flags
& cgiCurrentInsertBefore
)) {
93 LEGlyphID
*insertGlyphs
= glyphStorage
.insertGlyphs(currGlyph
, count
+ 1);
94 for (i
= 0; i
< count
; i
++, currIndex
++) {
95 insertGlyphs
[i
] = insertionTable
[currIndex
];
97 insertGlyphs
[i
] = glyphStorage
[currGlyph
];
98 glyphStorage
.applyInsertions();
100 LEGlyphID
*insertGlyphs
= glyphStorage
.insertGlyphs(currGlyph
, count
+ 1);
101 insertGlyphs
[0] = glyphStorage
[currGlyph
];
102 for (i
= 1; i
< count
+ 1; i
++, currIndex
++) {
103 insertGlyphs
[i
] = insertionTable
[currIndex
];
105 glyphStorage
.applyInsertions();
108 // inserted as a split-vowel-like insertion
109 // extra glyph(s) will be inserted some distance away from the current glyph
110 if (!(flags
& cgiCurrentInsertBefore
)) {
111 LEGlyphID
*insertGlyphs
= glyphStorage
.insertGlyphs(currGlyph
, count
+ 1);
112 for (i
= 0; i
< count
; i
++, currIndex
++) {
113 insertGlyphs
[i
] = insertionTable
[currIndex
];
115 insertGlyphs
[i
] = glyphStorage
[currGlyph
];
116 glyphStorage
.applyInsertions();
118 LEGlyphID
*insertGlyphs
= glyphStorage
.insertGlyphs(currGlyph
, count
+ 1);
119 insertGlyphs
[0] = glyphStorage
[currGlyph
];
120 for (i
= 1; i
< count
+ 1; i
++, currIndex
++) {
121 insertGlyphs
[i
] = insertionTable
[currIndex
];
123 glyphStorage
.applyInsertions();
128 if (flags
& cgiSetMark
) {
129 markGlyph
= currGlyph
;
132 if (!(flags
& cgiDontAdvance
)) {
139 void ContextualGlyphInsertionProcessor2::endStateTable()