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(
22 const LEReferenceTo
<MorphSubtableHeader2
> &morphSubtableHeader
, LEErrorCode
&success
)
23 : StateTableProcessor2(morphSubtableHeader
, success
)
25 contextualGlyphHeader
= LEReferenceTo
<ContextualGlyphInsertionHeader2
>(morphSubtableHeader
, success
);
26 if(LE_FAILURE(success
) || !contextualGlyphHeader
.isValid()) return;
27 le_uint32 insertionTableOffset
= SWAPL(contextualGlyphHeader
->insertionTableOffset
);
28 insertionTable
= LEReferenceToArrayOf
<le_uint16
>(stHeader
, success
, insertionTableOffset
, LE_UNBOUNDED_ARRAY
);
29 entryTable
= LEReferenceToArrayOf
<ContextualGlyphInsertionStateEntry2
>(stHeader
, success
, entryTableOffset
, LE_UNBOUNDED_ARRAY
);
32 ContextualGlyphInsertionProcessor2::~ContextualGlyphInsertionProcessor2()
36 void ContextualGlyphInsertionProcessor2::beginStateTable()
41 void ContextualGlyphInsertionProcessor2::doInsertion(LEGlyphStorage
&glyphStorage
,
45 le_bool
/* isKashidaLike */,
47 LEErrorCode
&success
) {
48 LEGlyphID
*insertGlyphs
= glyphStorage
.insertGlyphs(atGlyph
, count
+ 1, success
);
50 if(LE_FAILURE(success
) || insertGlyphs
==NULL
) {
54 // Note: Kashida vs Split Vowel seems to only affect selection and highlighting.
55 // We note the flag, but do not layout different.
56 // https://developer.apple.com/fonts/TTRefMan/RM06/Chap6mort.html
58 le_int16 targetIndex
= 0;
60 // insert at beginning
61 insertGlyphs
[targetIndex
++] = glyphStorage
[atGlyph
];
64 insertGlyphs
[count
] = glyphStorage
[atGlyph
];
68 insertGlyphs
[targetIndex
++] = insertionTable
.getObject(index
++, success
);
70 glyphStorage
.applyInsertions();
73 le_uint16
ContextualGlyphInsertionProcessor2::processStateEntry(LEGlyphStorage
&glyphStorage
, le_int32
&currGlyph
,
74 EntryTableIndex2 index
, LEErrorCode
&success
)
76 const ContextualGlyphInsertionStateEntry2
*entry
= entryTable
.getAlias(index
, success
);
78 if(LE_FAILURE(success
)) return 0; // TODO- which state?
80 le_uint16 newState
= SWAPW(entry
->newStateIndex
);
81 le_uint16 flags
= SWAPW(entry
->flags
);
83 le_int16 markIndex
= SWAPW(entry
->markedInsertionListIndex
);
85 le_int16 count
= (flags
& cgiMarkedInsertCountMask
) >> 5;
86 le_bool isKashidaLike
= (flags
& cgiMarkedIsKashidaLike
);
87 le_bool isBefore
= (flags
& cgiMarkInsertBefore
);
88 doInsertion(glyphStorage
, markGlyph
, markIndex
, count
, isKashidaLike
, isBefore
, success
);
91 le_int16 currIndex
= SWAPW(entry
->currentInsertionListIndex
);
93 le_int16 count
= flags
& cgiCurrentInsertCountMask
;
94 le_bool isKashidaLike
= (flags
& cgiCurrentIsKashidaLike
);
95 le_bool isBefore
= (flags
& cgiCurrentInsertBefore
);
96 doInsertion(glyphStorage
, currGlyph
, currIndex
, count
, isKashidaLike
, isBefore
, success
);
99 if (flags
& cgiSetMark
) {
100 markGlyph
= currGlyph
;
103 if (!(flags
& cgiDontAdvance
)) {
110 void ContextualGlyphInsertionProcessor2::endStateTable()